Skip to content
D DocNectar

Free Affine Cipher Encoder and Decoder

Encrypt or decrypt text with an affine cipher, combining a multiplication and a shift for a larger key space than Caesar alone.

100% Free No Signup Works on all devices

Built and fact-checked by the DocNectar team — see our editorial standards

Thanks for rating!

Key Features

Instant Calculation

Get accurate results in real time with our optimized algorithm.

Mobile Friendly

Fully responsive design. Works on all devices & screen sizes.

Privacy Focused

Your data stays on your device. We don't store any inputs.

100% Free

No hidden costs. This tool is completely free forever.

The affine cipher generalizes the Caesar cipher by combining a multiplication step with a shift step, giving a much larger set of possible keys than a simple shift alone.

This tool encrypts or decrypts text using an affine cipher with two keys you choose: a multiplier (a) and a shift (b).

How it works

Enter your text along with two numbers: a (which must share no common factor with 26 — valid choices are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, or 25) and b (any number from 0 to 25). To encrypt, each letter's position is multiplied by a, then b is added, wrapping mod 26. To decrypt, the reverse math uses the modular inverse of a. Non-letter characters are left unchanged.

  1. Enter mode.
  2. Enter text.
  3. Enter a (must be coprime with 26, e.g. 5).
  4. Enter b (0-25).
  5. Click Calculate to see your results.

Examples

a = 5, b = 8

"Attack at dawn" encrypted with a = 5 and b = 8 becomes "Izzisg iz xiov".

Who should use it

  • Teaching modular arithmetic and substitution ciphers.
  • Puzzle and escape-room style word games with a bit more complexity than Caesar.

Industry applications

  • Cryptography education
  • Games and puzzles

Advantages

  • Larger key space than a plain Caesar shift (312 combinations vs. 25).
  • A useful next step for learning modular arithmetic in cryptography.

Limitations

  • Still trivially breakable with modern computing — no real security.

Common mistakes to avoid

  • Picking a value for a that isn't coprime with 26 (like 2, 4, or 13) — the tool will reject these since they can't be reversed.
  • Forgetting that both a and b must match exactly between encryption and decryption.

Best practices

  • Use the affine cipher for puzzles or to explore how combining a shift with a multiplication changes a classical cipher — not for protecting real secrets.

Tips

  • If decryption doesn't produce readable text, double check that a and b exactly match the values used for encryption.

Frequently asked questions

Yes, with no signup and no limit on how many conversions you run.
a must be coprime with 26 (share no common factor) so the cipher can be reversed — otherwise multiple letters would encrypt to the same ciphertext letter, making decryption impossible. The tool tells you if your choice of a is invalid.
No — with only 12 valid values for a and 26 for b, there are just 312 possible keys, all breakable almost instantly by computer. It's used for education and puzzles, not real security.
They pass through unchanged — only letters A-Z and a-z are transformed.

Get new calculators and guides in your inbox

No spam — just new tools like Affine Cipher Tool and practical guides.

Favorites