CS Unplugged activity
Caesar Cipher: cracking it with letter frequency
If you have done the first Caesar cipher activity, you already know you can crack a short message by trying all 25 possible keys by hand. That gets slow once a message is long. This activity uses a shortcut real codebreakers used for centuries before computers existed: you never have to guess a single key. The message itself tells you.
Why this works at all
English is not a random pile of letters. Some letters show up constantly (you are looking at four Es already in this sentence) and some hardly ever appear at all. That pattern holds true no matter what a piece of English text is about, as long as it is long enough.
A Caesar cipher does not change how often each letter shows up. It just renames every letter to a different one, consistently, everywhere in the message. So whichever letter was most common in the original message is still most common in the encoded one. It is just wearing a different letter’s name now. Find the most common letter in the ciphertext, assume it is standing in for the most common letter in English, and you have almost certainly found the key.
What English letters usually look like
Here is roughly how often each letter shows up in ordinary English writing (out of every 100 letters). Leave the last two columns of each row blank for now. You will use them in a moment.
| Letter | Typical | Your tally | Count |
|---|---|---|---|
| A | |||
| B | |||
| C | |||
| D | |||
| E | |||
| F | |||
| G | |||
| H | |||
| I | |||
| J | |||
| K | |||
| L | |||
| M |
| Letter | Typical | Your tally | Count |
|---|---|---|---|
| N | |||
| O | |||
| P | |||
| Q | |||
| R | |||
| S | |||
| T | |||
| U | |||
| V | |||
| W | |||
| X | |||
| Y | |||
| Z |
The bar length is how common each letter is. Notice how a handful of letters (E, T, A, O, I, N) do most of the work, while letters like J, Q, X, and Z barely show up.
Tally the passage
Here is a message, encoded with a single key. Read across it letter by letter, and for every letter, make a tally mark in that letter’s “Your tally” box above. Skip the spaces, they are not letters. When you are done, count up the marks and write each total in the “Count” column.
CZMZED ESLE PIAWZCP ESP ZNPLY QLNP L SLCOPC UZM ESLY CZMZED ZY WLYO ESP HLEPC MWZNVD CLOTZ DTRYLWD DZ L CZG DELJD NZYYPNEPO EZ TED ATWZE HTES L WZYR EPESPC TYDEPLO PGPCJ NLXPCL PGPCJ ESCFDEPC LYO PGPCJ DPYDZC DPYOD TED OLEL OZHY ESLE DLXP NLMWP HSTNS TD HSJ PYRTYPPCD AWLY ESP HTCTYR DZ NLCPQFWWJ MPQZCP ESP CZMZE PGPC EZFNSPD ESP HLEPC
Find the shift
Look at your counts. One letter should stand out as far more common than the rest, the same way E stood out in the reference chart.
- Which letter showed up the most?
- Assume that letter is standing in for E. Count how many places forward from E you would have to shift to reach it. That count is your guess for the key.
- Use that key with your shift table or wheel from the first cipher activity to decode the first few words of the passage. Do they look like real English?
If the first few words look like nonsense, the second most common letter is worth a try instead. E is usually the most common letter, but a short passage can occasionally have T or A edge it out.
Learn more about the Caesar cipher.
Decode the rest
Once your key checks out, decode the whole passage below.
Check your answers
Your tally should come out to:
| A | 3 |
| B | 0 |
| C | 23 |
| D | 21 |
| E | 29 |
| F | 3 |
| G | 5 |
| H | 7 |
| I | 1 |
| J | 6 |
| K | 0 |
| L | 25 |
| M | 7 |
| N | 10 |
| O | 9 |
| P | 38 |
| Q | 3 |
| R | 4 |
| S | 16 |
| T | 12 |
| U | 1 |
| V | 1 |
| W | 10 |
| X | 2 |
| Y | 17 |
| Z | 23 |
P is the most common letter in the ciphertext, standing in for E. That makes the key 11.
Decoded, the passage reads:
Robots that explore the ocean face a harder job than robots on land the water blocks radio signals so a rov stays connected to its pilot with a long tether instead every camera every thruster and every sensor sends its data down that same cable which is why engineers plan the wiring so carefully before the robot ever touches the water
Version history
- Loading commit history…