Affine Cipher
Beta: this tool hasn't been fully reviewed yet. Double-check results before relying on them.
Only these 12 values can be undone.
0 to 25.
Results
| Plain | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cipher |
Your input is too long to share as a link, so the page address no longer includes it.
The affine cipher numbers the letters A = 0 to Z = 25, multiplies each by a key a, adds a key b and wraps around at 26. It sits between the Caesar cipher (a = 1, a pure shift) and Atbash (a = 25, b = 25, the alphabet reversed). With only 312 possible keys, it is a classic exercise in modular arithmetic rather than real protection.
How to use it
- Choose Encode or Decode.
- Type the text.
- Pick key a and key b; the result and the letter mapping update as you type.
Examples: with a = 5 and b = 8, AFFINE CIPHER becomes IHHWVC SWFRCP, and decoding it brings back AFFINE CIPHER. With a = 25 and b = 25, HELLO becomes SVOOL, exactly as in Atbash.
Questions and answers
Why can't a be any number?
To decode, you multiply by the inverse of a modulo 26, and only numbers sharing no factor with 26 have one: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25. With a = 2, for example, A and N would both become the same letter.
How is it broken?
Each letter always maps to the same letter, so letter frequencies give it away: the most common cipher letter is probably E. Two known letters are enough to solve for a and b, and trying all 312 keys takes a computer no time at all.
What happens to spaces, digits and accents?
Only the letters A to Z are changed, in upper and lower case. Everything else is kept as it is.
Link with pre-filled values
Add # and these parameters to the end of this page's address to open the tool with values already filled in.
| Parameter | What it sets |
|---|---|
text | Text to encode or decode. |
a | Multiplier key: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 or 25. |
b | Shift key, 0 to 25. |
mode | encode or decode. |
Example: https://toolabelle.com/affine-cipher/#text=AFFINE+CIPHER&a=5&b=8&mode=encode