Cipher Table

Tool

Frequency analysis

Count the letters in a message and compare them with ordinary English. It is the oldest codebreaking technique there is, and still the first thing to try.

Letter frequencies

Red bars are your text. Black lines mark what English would give.

Your textTypical English

How to read the chart

In English the bars make a recognisable skyline: a tall peak at E, strong bars at A, I, N, O, S and T, and almost nothing at J, Q, X and Z. A cipher can't easily hide that shape. It can only move it or flatten it.

  • The red bars match the black lines. The letters are unchanged, so either this is plain English or the letters have been rearranged by a transposition such as rail fence.
  • The same skyline, slid sideways. A Caesar shift. The sample text loaded above is one: its tallest bar is at H where E should be, three places along, so the shift is 3.
  • A skyline with the right mix of tall and short bars, in the wrong places. A simple substitution. Match the tallest bars to E, T, A and work from there, or use the cryptogram solver.
  • Nearly level. A polyalphabetic cipher such as Vigenère, which uses several alphabets in turn to even the counts out.

The index of coincidence

The index of coincidence boils the chart down to a single number: the chance that two letters drawn at random from the text are identical. Lumpy distributions score high and flat ones score low. English is about 0.067; perfectly even letters give 0.038.

Its value is that it doesn't care which letters are common, only that some are. So it stays at 0.067 through any simple substitution or transposition, and drops only when a cipher really is mixing alphabets. William Friedman introduced it in 1922, in what is often called the most important single publication in cryptology.

A short history

Around the year 850, in Baghdad, the scholar al-Kindi wrote A Manuscript on Deciphering Cryptographic Messages. In it he explained that if you take a long sample of ordinary writing and count its letters, then count the symbols in a secret message in the same language, the most frequent symbol will stand for the most frequent letter, the next for the next, and so on.

It is thought the idea grew out of close textual study of the Qur'an, where scholars had counted letter and word frequencies for other reasons. The effect on cryptography was permanent: from then on, a cipher that merely replaced each letter with a fixed symbol was no longer safe, and cipher makers spent the next thousand years looking for ways to flatten the chart.

Questions people ask

What is frequency analysis?

Counting how often each letter, or group of letters, appears in a piece of ciphertext, and comparing the counts with what is normal for the language. Because languages use their letters very unevenly, the comparison reveals which cipher symbols stand for which letters.

What are the most common letters in English?

In order: E, T, A, O, I, N, S, H, R, D, L, U. E alone accounts for about one letter in eight. The rarest are J, X, Q and Z.

What are the most common letter pairs and triples?

The commonest pairs (bigrams) are TH, HE, IN, ER, AN, RE, ON, AT, EN and ND. The commonest triples (trigrams) are THE, AND, ING, ENT, ION, HER, FOR and THA.

Which ciphers does frequency analysis break?

Any cipher where each letter is always replaced by the same symbol: Caesar, Atbash, affine, keyword and random substitution, pigpen. It also breaks Vigenère once the key length is known, by analysing each key position separately. It does not directly break transposition ciphers, though it identifies them.

Who invented frequency analysis?

The earliest known description is by the Arab philosopher and mathematician al-Kindi, in Baghdad in the ninth century.