By Debmedia Technologies LLP · Kolkata, India · Updated
What Is It and When Do You Need It?
The affine cipher is a Caesar cipher with a multiplication added. Multiplying by a spreads the letters out, and adding b shifts them. It gives 312 possible keys, still far too few to be secure, but a good step up for teaching.
Enter text, the two keys and the direction.
How to Use This Tool
- Type or paste your text.
- Enter a valid key a and a key b.
- Choose encrypt or decrypt.
- Press Run.
How the Calculation Works
Letters are numbered 0 to 25. Encryption computes (a × x + b) mod 26. Decryption computes a⁻¹ × (y − b) mod 26, where a⁻¹ is the number that gives 1 when multiplied by a modulo 26. The tool tests that a and 26 share no factor.
Worked Example
With a = 5 and b = 8, AFFINECIPHER becomes IHHWVCSWFRCP, the standard example.
Common Uses
- Teaching modular arithmetic.
- Puzzles.
- Studying cipher families.
- Homework checks.
Tips and Common Mistakes
- Pick a from the list of 12 allowed values.
- a = 25 and b = 25 is the Atbash cipher.
- Try brute force over all 312 keys by hand only for short texts.
Related Tools
Next, you may need the Caesar cipher, Atbash cipher, Vigenère cipher, A1Z26 cipher.
Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.
Frequently Asked Questions
Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.