Cipher
calculator.
Encrypt and decrypt with six classic ciphers, or break a Caesar shift with no key.
- Letters
- 27
- Characters
- 35
- Key
- 3
Every letter moves forward the same 3 places, counting on from Z to A, so the letter counts keep the shape of English, only moved along. That is why the sweep of every shift ranks shift 3 first.
Letter counts against English
Slide to try a shift27 letters. The most common are H (22.2%), W (18.5%), R (14.8%). The marks show English letter shares moved 3 places, as a shift of 3 would write them; when the bars and marks line up, the shift is right.
Letter counts
| Letter | Count | Yours | English |
|---|---|---|---|
| A | 0 | 0.0% | 0.1% |
| B | 0 | 0.0% | 2.0% |
| C | 0 | 0.0% | 0.1% |
| D | 3 | 11.1% | 8.2% |
| E | 0 | 0.0% | 1.5% |
| F | 0 | 0.0% | 2.8% |
Working
- 1The ruleMove each letter forward 3 places, wrapping from Z to A
- 2Letter 1M (12) → moves 3 → P (15)
- 3Letter 2E (4) → moves 3 → H (7)
- 4Check: decrypt the answergives your text back
Letter by letter
| Letter | From | Shift | To |
|---|---|---|---|
| 1 | M (12) | 3 | P (15) |
| 2 | e (4) | 3 | h (7) |
| 3 | e (4) | 3 | h (7) |
| 4 | t (19) | 3 | w (22) |
| 5 | m (12) | 3 | p (15) |
| 6 | e (4) | 3 | h (7) |
| 7 | a (0) | 3 | d (3) |
| 8 | t (19) | 3 | w (22) |
Plain ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher DEFGHIJKLMNOPQRSTUVWXYZABC
All 26 shifts, most English-like first
| Shift | Score | Decryption |
|---|---|---|
| 3 | 21.9 | Meet me at the old oak tree at noon |
| 22 | 98.9 | Tlla tl ha aol vsk vhr ayll ha uvvu |
| 14 | 102.0 | Btti bt pi iwt das dpz igtt pi cddc |
| 15 | 104.7 | Assh as oh hvs czr coy hfss oh bccb |
| 9 | 114.7 | Gyyn gy un nby ifx iue nlyy un hiih |
Each row moves the ciphertext back by that shift and scores the letters against English (Lewand). 26 letters, so 26 tries cover every key.
How it's worked out
Each cipher turns letters into numbers first: A is 0, B is 1 and so on up to Z at 25. It does the sum, then wraps round past Z back to A. Mathematicians write that wrap as "mod 26", the remainder after dividing by 26.
Caesar adds the same shift to every letter. The Roman writer Suetonius says Caesar wrote D for A, a shift of 3. ROT13 is a shift of 13, and Atbash swaps A with Z, B with Y and so on.
Vigenère uses a keyword. Each key letter gives its own shift, and the keyword repeats along the message. A Purdue lecture describes it as a set of Caesar ciphers, one for each letter of the key.
Affine multiplies before it adds. Stinson's textbook uses a = 7 and b = 3, which turns hot into AXG. To undo it you multiply by 15, because 7 times 15 leaves 1 after dividing by 26. Only 12 values of a have such a partner.
Rail fence does not change any letter. It writes the text in a zigzag over a number of rows, then reads the rows one after another.
Cracking a Caesar shift tries all 26 shifts. For each one it counts the letters and compares them with how often each letter appears in English, using the chi-squared score. The lowest score is the most English-looking, and it is nearly always the answer for a sentence or more of text.
Worked examples
Maya writes a clue for her escape room
Maya wants a clue that a team can break with a little thought. With a shift of 3, "Meet me at the old oak tree at noon" becomes "Phhw ph dw wkh rog rdn wuhh dw qrrq". Each M becomes P, and the spaces stay put, so the word lengths still help the team.
She checks how easy it is. The sweep of every shift puts shift 3 first, with a score of 21.9 against 98.9 for the next best. So a team with a phone would solve it at once; a team with pen and paper still has work to do.
Jonah breaks a geocache clue with no key
Jonah finds "Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj" in a cache log. He chooses Crack. Shift 3 scores 109.3 and reads "The quick brown fox jumps over the lazy dog".
The next best, shift 9, scores 122.9, not far behind, so the tool says to read both. Shift 9 gives "Nby kocwe vliqh zir dogjm ipyl nby futs xia", which is plainly not English, so Jonah keeps shift 3.
Why so close? The sentence uses every letter of the alphabet at least once, so rare letters such as J, Q, X and Z show up far more than in normal English. Maya's clue, plain everyday words, scored 21.9; this one scores 109.3 even with the right shift.
A class tries Vigenère with the key LEMON
A teacher puts "Attack at dawn" on the board with the key LEMON. The five key letters give shifts of 11, 4, 12, 14 and 13, used in turn, and the result is "Lxfopv ef rnhr". Decrypting with the same key gives "Attack at dawn" back.
The two T letters in "attack" come out as different letters, because they sit under different key letters. That is the point of the cipher. On a longer passage the class sees the effect in numbers: the index of coincidence is 0.086 for the plain text, 0.086 after a Caesar shift (unchanged) and 0.045 after Vigenère.
Reading your result
The chi-squared score measures how far the letter counts are from English. Lower is better. What matters most is the gap: a best score far below the second means a clear answer, while two close scores mean you should read both decryptions.
The index of coincidence is the chance that two letters picked at random from the text are the same. Lewand's English letter shares give about 0.065, and letters spread evenly give 0.038. A one-alphabet cipher such as Caesar, Atbash or affine keeps the English value, and so does rail fence. Vigenère pulls it down toward the random value, more so with a longer key.
The letter chart shows the same idea as a picture. In English, E, T and A are the commonest letters. After a Caesar shift those peaks move along by the shift. Slide the shift until the English marks sit on top of the bars, and you have found the key by eye.
None of these ciphers keeps a secret. Caesar has only 25 useful shifts, and the others fall to letter counts or to the methods the lecture describes. Use them for puzzles, games and teaching, and use modern encryption for anything private.
Common mistakes
- Trusting a crack on a very short text. Three letters are not enough to count. For "Fdw" the cracker puts shift 18 first, reading "Nle", while the real word, "Cat", is shift 3 in second place. Read the list, not just the top line.
- Mixing up the direction of the shift. A shift of 3 to encrypt is a shift of 3 back to decrypt, which is the same as a shift of 23 forward. Choose Decrypt rather than typing a negative number, and the tool does the turn for you.
- Using a multiplier that shares a factor with 26. With an even a, or 13, two different letters end up as the same letter, and the message cannot be read back. That is why the a box offers only the values that work.
- Running ROT13 twice by mistake. It undoes itself: "Spoiler" becomes "Fcbvyre", and a second pass gives "Spoiler" back. If your text looks unchanged, it has been encoded twice.
Questions people ask
Sources
- Suetonius, The Life of Julius Caesar, section 56 (LacusCurtius translation)
- Stinson, Cryptography: Theory and Practice, section 1.1.4, the affine cipher
- Nita-Rotaru, CS355 Cryptography, lecture 3: Vigenère cipher (Purdue University)
- Relative frequencies of letters in general English plain text, after Lewand (Wellesley College)