Frequency Analysis Guide
How to break a substitution cipher by counting letters, with a worked geocache example.
A substitution cipher swaps every letter for another one, but it cannot hide how often each letter is used. In English, E is about one letter in eight, while Q, J, X and Z barely show up. Count the letters of a ciphertext and the most common one is very likely standing in for E. That idea, called frequency analysis, plus a few word patterns, is enough to break most of the letter-swap ciphers you will meet on a mystery cache.
This guide explains what to count, what English looks like, and then solves a real example one step at a time. Every step can be checked in our own tools.
What frequency analysis can break
It works on any monoalphabetic substitution: every plaintext letter always becomes the same cipher letter, everywhere in the message. That covers a lot of geocache puzzles:
- Caesar and ROT13, where the whole alphabet slides along by a fixed amount.
- Atbash, where the alphabet is reversed.
- Keyword alphabets and fully scrambled alphabets, the Substitution cipher.
- Newspaper style cryptograms (Aristocrats keep the spaces, Patristocrats remove them).
- Symbol alphabets like Pigpen, the Dancing Men or a made-up set of shapes. Give each different symbol a letter of its own, any letter, and solve the result the same way. The Code Tables may already name the symbols for you.
It does not directly break ciphers that change the substitution as they go, like Vigenère, or ciphers that only shuffle the letters around. The section near the end shows how to recognize those.
What English looks like
These are the share of each letter in ordinary English text. Exact figures differ a little from one source and one kind of text to another, but the shape is always the same: a few letters do most of the work. The old typesetters' order ETAOIN SHRDLU is an easy way to remember the top twelve.
| Letter | Share of letters |
|---|---|
| E |
12.7%
|
| T |
9.1%
|
| A |
8.2%
|
| O |
7.5%
|
| I |
7.0%
|
| N |
6.7%
|
| S |
6.3%
|
| H |
6.1%
|
| R |
6.0%
|
| D |
4.3%
|
| L |
4.0%
|
| C |
2.8%
|
| U |
2.8%
|
| Letter | Share of letters |
|---|---|
| M |
2.4%
|
| W |
2.4%
|
| F |
2.2%
|
| G |
2.0%
|
| Y |
2.0%
|
| P |
1.9%
|
| B |
1.5%
|
| V |
1.0%
|
| K |
0.8%
|
| J |
0.2%
|
| X |
0.2%
|
| Q |
0.1%
|
| Z |
0.1%
|
Words and pairs worth knowing
Single letters only get you started. When the spaces are kept, the words themselves give far more away.
- One-letter words are almost always A or I.
- Two-letter words: OF TO IN IS IT AT AS BE BY ON OR SO IF UP WE NO GO DO AN
- Three-letter words: THE AND FOR ARE BUT NOT YOU ALL CAN HAD WAS ONE OUR OUT. A three-letter word that repeats a lot is nearly always THE.
- Common pairs (bigrams): TH HE IN ER AN RE ON AT EN ND
- Common triples (trigrams): THE AND ING ENT ION HER FOR THA
- Doubled letters: LL EE SS OO TT FF are common, while AA, II and UU almost never happen.
- After an apostrophe: 'S 'T 'LL 'RE 'VE 'D, so a lone letter after an apostrophe is usually S or T.
Geocache puzzles have their own vocabulary. Words like CACHE FINAL COORDINATES NORTH WEST EAST SOUTH POINT LOG and spelled-out numbers such as ZERO SEVEN THREE show up again and again. If you suspect one, try it. A wrong guess costs nothing.
A worked example
Here is the kind of message you might find on a puzzle cache page. The spaces and punctuation were left alone, which makes it much easier.
UOEE PHGO, JRZZEO MHESOL. XHR TWSO YLWYDOP QTO YHPO WGP OWLGOP QTO IBGWE YHHLPBGWQOM. QTO YWYTO BM W MFWEE NLOOG WFFH YWG QRYDOP RGPOL QTO LHHQM HI W IWEEOG HWD, WAHRQ QOG IOOQ HII QTO QLWBE. ALBGN XHRL HUG JOG, AOYWRMO QTO EWMQ IBGPOL QHHD HRLM. JEOWMO MBNG QTO EHN, QLWPO IWBLEX, WGP JRQ QTO YWYTO AWYD OVWYQEX UTOLO XHR IHRGP BQ MH QTO GOVQ MOODOL YWG OGCHX QTO TRGQ.
Try it yourself before reading on. In the partly solved blocks below, the ciphertext is in gray and what we know so far is underneath it, with a dot for each letter we have not worked out yet.
Step 1. Count the letters
The message has 291 letters. Sorted by count, the top of the list looks like this, next to the English letter at the same rank and the letter each one turned out to be:
| Rank | Cipher | Count | English | Answer |
|---|---|---|---|---|
| 1 | O | 45 (15.5%) | E | E |
| 2 | W | 26 (8.9%) | T | A |
| 3 | Q | 25 (8.6%) | A | T |
| 4 | H | 23 (7.9%) | O | O |
| 5 | G | 21 (7.2%) | I | N |
| 6 | L | 16 (5.5%) | N | R |
| 7 | E | 15 (5.2%) | S | L |
| 8 | T | 15 (5.2%) | H | H |
| 9 | Y | 14 (4.8%) | R | C |
| 10 | P | 12 (4.1%) | D | D |
O is far ahead of everything else, so it is almost certainly E. The next four, W Q H G, are all close together, so they are probably T, A, O, I and N in some order, but the counts alone cannot say which. The Answer column is where we will end up: only four of the ten ranks match English exactly. Frequency ranks are clues, not a key. You confirm them with words.
Step 2. Find THE
The three-letter word QTO appears 10 times and ends in our E. That is THE, which gives Q = t and T = h.
UOEE PHGO, JRZZEO MHESOL. XHR ·e·· ···e, ·····e ····e·. ··· TWSO YLWYDOP QTO YHPO WGP h··e ·····e· the ···e ··· OWLGOP QTO IBGWE YHHLPBGWQOM. e···e· the ····· ········te·. QTO YWYTO BM W MFWEE NLOOG the ···he ·· · ····· ··ee· WFFH YWG ···· ···
Step 3. A one-letter word, then AND
W stands alone, so it is A or I. It is also the second most common letter, which fits A much better. Then WGP, which appears twice, is a three-letter word starting with A: AND is the obvious guess, giving G = n and P = d. The guess checks out straight away, because OWLGOP now reads ea·ned.
UOEE PHGO, JRZZEO MHESOL. XHR ·e·· d·ne, ·····e ····e·. ··· TWSO YLWYDOP QTO YHPO WGP ha·e ··a··ed the ··de and OWLGOP QTO IBGWE YHHLPBGWQOM. ea·ned the ··na· ····d·nate·. QTO YWYTO BM W MFWEE NLOOG the ·a·he ·· a ··a·· ··een WFFH YWG a··· ·an
Step 4. Use the repeated letters
YWYTO is ·a·he with the first and third letters the same. On a geocache page that can only be CACHE, so Y = c. That turns YHPO into c·de, which is CODE, so H = o. That fits the counts too: H is the fourth most common letter, like O in English, and HH shows up as a double three times, as OO does in words like TOOK and ROOTS.
UOEE PHGO, JRZZEO MHESOL. XHR ·e·· done, ·····e ·o··e·. ·o· TWSO YLWYDOP QTO YHPO WGP ha·e c·ac·ed the code and OWLGOP QTO IBGWE YHHLPBGWQOM. ea·ned the ··na· coo·d·nate·. QTO YWYTO BM W MFWEE NLOOG the cache ·· a ··a·· ··een WFFH YWG a··o can
Step 5. Fill in the words that are nearly done
Now whole words start to give themselves up. ha·e is HAVE (S = v), c·ac·ed is CRACKED (L = r, D = k), and ·o· at the start of a sentence is YOU (X = y, R = u). Each new letter lands somewhere else and has to make sense there too: ea·ned becomes EARNED, so the guess for r was right.
UOEE PHGO, JRZZEO MHESOL. XHR ·e·· done, ·u···e ·o·ver. you TWSO YLWYDOP QTO YHPO WGP have cracked the code and OWLGOP QTO IBGWE YHHLPBGWQOM. earned the ··na· coord·nate·. QTO YWYTO BM W MFWEE NLOOG the cache ·· a ··a·· ·reen WFFH YWG a··o can
Step 6. Keep going
coord·nate· is COORDINATES (B = i, M = s), ··na· is FINAL (I = f, E = l), a··o can is AMMO CAN (F = m) and ·reen is GREEN (N = g).
UOEE PHGO, JRZZEO MHESOL. XHR ·ell done, ·u··le solver. you TWSO YLWYDOP QTO YHPO WGP have cracked the code and OWLGOP QTO IBGWE YHHLPBGWQOM. earned the final coordinates. QTO YWYTO BM W MFWEE NLOOG the cache is a small green WFFH YWG ammo can
Notice where the letter I came from. In English it is the fifth most common letter, but here it was cipher B, only fifteenth, because this message happens to use few words with I in them. If you had matched the top five by rank alone, you would have put I in the wrong place and stalled. That is why every guess needs a word to back it up.
Step 7. Finish and read it through
The last few letters only appear in a word or two each: ·u··le is PUZZLE, and the rest of the message gives BECAUSE, EXACTLY, ENJOY and OWN. Then read the whole message from start to finish. If every word makes sense, you are done. If one word comes out as nonsense, one of your guesses is wrong, and that word tells you which letters to look at again.
Step 8. Read the key back
Write the cipher letter you found under each plaintext letter, in alphabetical order, and the key often explains itself:
plain abcdefghijklmnopqrstuvwxyz cipher WAYPOINTBCDEFGHJ?LMQRSUVXZ
It starts with the word WAYPOINT, and after that the unused letters simply follow in alphabetical order. That is a keyword alphabet. Spotting it fills in the one gap: the message never uses Q, so its cipher letter could not be counted, but the alphabetical run says it must be K. When you only have part of a key, look for a word at the start like this.
When the counts mislead
- Short messages. Under about 100 letters the ranks wander a lot, and a single sentence may not use E much at all. Lean on word shapes instead: one-letter words, THE, AND, doubled letters and repeated patterns like ·a·he.
- No spaces. When the text comes in one run or in blocks of five, look for a three-letter group that repeats often. It is usually THE, and ING, AND and ION are the next ones to try.
- Unusual text on purpose. Puzzle setters sometimes write without the letter E, or pack the message with rare letters, just to throw off counting. If nothing fits, stop trusting the counts and work from words.
- Another language. Every language has its own top letters. The Cryptogram Solver can score against 18 languages.
Is it even a substitution cipher?
Before spending an hour on a message, check that frequency analysis can work on it at all. The Frequency Analysis tool shows a number called the index of coincidence (IoC), the chance that two letters picked at random from the text are the same. Swapping letters for other letters does not change it.
- IoC around 0.065 to 0.070 means the letters are as uneven as English. Our example scores 0.0670. It is a substitution, a transposition, or plain text in disguise.
- The counts look like English and E is still on top, but nothing reads? The letters are real and only their order is scrambled. That is a transposition: try Columnar Transposition.
- The whole English shape is there, just moved along the alphabet (for example the biggest peak is on H, three letters after E)? It is a Caesar shift. The Caesar tool's Show all rotations button tries all 25 at once.
- IoC around 0.040 to 0.045 with fairly flat counts means several alphabets are in use, like Vigenère. Counting the whole message will not work. Try the Vigenère solver.
Not sure at all? Paste it into the Cipher Identifier, which runs these checks and more and suggests where to go next.
The short version
- Check the IoC. Near 0.067 means a substitution is worth trying.
- Count the letters. The top one is probably E, and the next few are T, A, O, I, N in some order.
- Find THE, then the one-letter words, then AND.
- Use repeated and doubled letters to finish words that are nearly done.
- Make sure every new letter makes sense everywhere else it appears.
- Read the whole message through, then write out the key and look for a keyword.