StringMash.com

Frequency analysis

Count how often each letter turns up and set it against English. It is the oldest way into a cipher, and still the first thing to try.

170 characters
Updates as you type
Commonest first, with English beside each

Show the steps
0%5%10%ABCDEFGHIJKLMNOPQRSTUVWXYZthis textEnglish
  1. 129 letters counted. Spaces, digits and punctuation are left out.
  2. The index of coincidence is 0.0778, close to English's 0.067, so each letter is probably always written the same way. No shift lines the counts up with English, so the letters have been swapped by a key: a substitution cipher. Match the commonest letters with E, T, A and O and work from there.

Using the frequency analysis tool

Paste the cipher text. The list gives every letter with its count and its share of the text, commonest first, next to how often that letter turns up in English. The chart shows the same thing: a bar for this text and a line across it for English.

Under the result, the working gives the index of coincidence and says what kind of cipher the counts point to, with a link to the tool to try next. Switch Count to pairs or triples to find repeated groups like TH, HE and THE.

Reading the counts

In English, E is the commonest letter at about 12.7%, then T at 9.1%, A at 8.2% and O at 7.5%. In a simple substitution cipher every E becomes the same letter, so whatever comes top of the list is probably E.

The sample above is the opening of A Tale of Two Cities in a keyword cipher. Its commonest letters are E, J, H and U. E stayed as itself, which keyword ciphers sometimes allow, J is T, and the three-letter word JTE that keeps repeating is THE. Take it to the cryptogram solver and fill those in.

Shorter messages show more variation, so a few sentences won't follow the table exactly. Whole novels have been written without the letter E. Use the counts as a starting point, then check the guesses against words.

The index of coincidence

The index of coincidence is the chance that two letters picked at random from the text are the same. William F. Friedman introduced it in 1922. English comes out around 0.067. Letters spread evenly over the alphabet give 1/26, about 0.0385.

A substitution cipher only renames the letters, so its index stays near English. A cipher like Vigenère, which writes the same letter differently in different places, flattens the counts and pulls the index down toward 0.0385. That's how the tool tells the two apart.

Where it comes from

The first known written explanation of frequency analysis is by Al-Kindi in the 9th century, in A Manuscript on Deciphering Cryptographic Messages. Cipher makers answered with homophones, several different symbols for the commonest letters, and later with ciphers that use many alphabets. Rotor machines in the 20th century were essentially immune to straightforward frequency analysis.

Questions

How much text do I need?

The more the better. Under 20 letters the tool won't guess at all, and around 100 letters or more is safer. Short messages can be lopsided by chance.

The counts look just like English but it doesn't read. Why?

The letters have been moved, not changed: a transposition cipher such as the [rail fence](/rail-fence-cipher) or a [columnar transposition](/columnar-transposition-cipher). Those keep every letter, so the counts don't change.

Where do the English figures come from?

From the table in Wikipedia's Letter frequency article, which takes them from Robert Lewand's Cryptological Mathematics (2000).

Is my text sent anywhere?

No. The counting happens in your browser.

Sources

Added and reviewed . What's new