- The ciphertext
| Clue | In the ciphertext | Common in the language |
|---|---|---|
| Pairs | ||
| Double letters | ||
| Repeated words | ||
| One-letter words |
Frequency analysis tool
In a substitution cipher every letter stands for another one, always the same. There are more possible keys than grains of sand on Earth, yet such ciphers have been broken for over a thousand years, because the disguise keeps the letter frequencies of the language. The most common letter is probably E, a one-letter word is A or I, and a word that keeps coming back may well be THE. Start a new puzzle, compare the counts with the language, fill in the key letter by letter, and let the solver finish when you get stuck. Every letter of the message has been replaced by another one, the same one throughout. Press New puzzle for a text to crack, or paste your own ciphertext. Compare the letter counts with the language: the most common letter is probably E. Click a letter in the text, or use the key, and type the letter you think it stands for. The clues list the common pairs, doubled letters and short words. Match by frequency fills in a first guess, Solve lets the computer finish the job, and with a puzzle from the app Hint gives away one letter and Check marks the wrong ones.
How it works
- Press New puzzle for an encrypted paragraph, or paste a ciphertext of your own, and choose its language.
- Compare the chart and the clues with the language, then click a letter in the text and type the letter you think it stands for. Match by frequency fills in a first guess.
- Press Solve to let the computer finish, or use Hint and Check to see how far you got.
How frequency analysis works
In ordinary English text about one letter in eight is an E, then come T, A, O, I and N, while J, Q, X and Z are rare. A substitution cipher changes the letters but not how often they occur, so the most common cipher letter is a good guess for E. Single letters rarely settle it, but patterns do: a one-letter word is A or I, a doubled letter is often LL, EE, SS or OO, and the commonest three-letter word is THE. Each guess makes the next one easier, until the words start to show through.
How the solver finishes the job
The solver starts from the frequency guess, or from the letters you already filled in, and scores the result by how ordinary its letter pairs are: TH and ER are common, QX never happens. It then swaps two letters of the key whenever that raises the score, until no swap helps. When it gets stuck it shakes the key a little and climbs again, keeping the best key it has found. A few hundred letters are usually enough to get nearly every letter right within a second.
Frequently asked questions
Why can't a computer just try every key?
A substitution cipher has 26! keys, about 4 × 10²⁶: more than a fast computer could test in billions of years. Frequency analysis avoids the search altogether, because every key leaves the letter frequencies of the language in place, and the solver only ever looks at keys that make the text more like the language.
How much text do I need?
The more the better. A few hundred letters are usually enough for the letter counts to point the right way and for the solver to get nearly every letter right. With a single sentence, many keys produce plausible-looking words, and even an expert can be led astray.
What is the difference with the Caesar cipher?
A Caesar cipher shifts every letter by the same amount, so there are only 25 keys and you can simply try them all. A substitution cipher can scramble the alphabet in any order, so the key has to be worked out letter by letter, which is where frequency analysis comes in.
Can ciphertext without spaces be solved?
Yes, but it is harder, because short words are among the best clues. Paste the text as it is: the letter counts and pairs still work, and the solver uses only pairs of letters.
Is my text sent anywhere?
No. Everything is counted and solved in your browser, and your text and key stay in this browser's local storage.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Go to Editor