Affine Cipher Decoder
Decode a message written in the affine cipher right in your browser, or switch to any other classical cipher.
Input
Output
Guide
How do you decode the affine cipher?
The affine cipher turns each letter's number x, from A = 0 to Z = 25, into a × x + b, counting around the alphabet. Decoding runs this backward: subtract the shift b, then multiply by the inverse of the multiplier a, the number that undoes the multiplication. The inverse of 5 is 21, as 5 × 21 = 105 is one more than 4 × 26. So with multiplier 5 and shift 8, S (18) gives 18 − 8 = 10, and 10 × 21 = 210 counts around to 2, which is C. You need both numbers of the key, and the tool finds the inverse for you:
| Multiplier (a) | 1 | 3 | 5 | 7 | 9 | 11 | 15 | 17 | 19 | 21 | 23 | 25 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Inverse | 1 | 9 | 21 | 15 | 3 | 19 | 7 | 23 | 11 | 5 | 17 | 25 |
Tool description
Paste the affine cipher text into the Cipher text box and set the Multiplier (a) and the Shift (b) it was encoded with, which start at 5 and 8. The message reads back in the Plain text box as you type, with its capitals, spaces, digits and punctuation where they were. Insert sample gives you Ucc yae iz zrc fipg iz vaav with the key 5 and 8, which decodes to See you at the park at noon. If the message uses another cipher, pick it from the Cipher menu. To reply, switch to encoding with the swap button between the boxes, which puts the result in the input, or open the Affine Cipher Encoder. Decoding happens in your browser.
Examples
| Cipher text | Multiplier (a) | Shift (b) | Plain text |
|---|---|---|---|
Oizcp zrc zaqizacu |
5 | 8 | Water the tomatoes |
Xvvc xv hc cmv sartvi fmro |
23 | 7 | Meet me at the flower shop |
Fgso dje fcstcs zgkoed |
19 | 6 | Pack the picnic basket |
Sgk gxkca czbkx lqpgd? |
15 | 2 | Ice cream after lunch? |
Jftp to iux qbrx bi ixo |
25 | 1 | Swim in the lake at ten |
How to find an unknown key
- There are only 312 keys, so given a message of a few words, the Cipher Identifier tries them all. When a key turns the text into English, it shows the result along with the key, as in
a = 5, b = 8. Multiplier 1 shows up as a Caesar shift, and multiplier 25 with shift 25 as Atbash, since those keys are those ciphers. - A one-letter word is usually
aorI, and since A is 0, the letter forais the shift. InRido d tunzv bg zdjv, the lonedis probablya, and D is 3. Set the Shift (b) to 3 and try the multipliers: 11 givesGrab a slice of cake.
How to recognize affine cipher text
- Word lengths, spaces and punctuation are untouched, and only the letters are swapped. A letter always stands for the same letter, so double letters stay double, and a repeated word looks the same each time, like
izin the sample. - Caesar and Atbash messages look just the same, so let the Cipher Identifier tell them apart.
Good to know
- There are no error messages: every text decodes with every key, and a wrong key just gives other letters.
- Accented letters are read as plain ones, so the decoded text has no accents.