What Is Frequency Analysis in Cryptography?


5 min read≈ 1,200 words3 questions · up to 3 points
What this is about
A message in which every letter has been swapped for another can be locked with more possible keys than anyone could ever try, and yet a ninth-century scholar could read it with pen and paper. You learn how he did it, how to break a short secret message yourself in four steps, and why the same trick sent a queen to her death.
In a nutshell· skip ahead
Frequency analysis is a way of breaking a cipher by counting how often each symbol appears. In a simple substitution cipher every letter is always replaced by the same symbol, so the symbols keep the letters' usual frequencies. The most common symbol in an English message probably stands for e, the next for t, and guesses about common words do the rest.
Imagine a message in which every letter has been swapped for another, with no rule behind the swaps. There are about 400 million billion billion ways to pair up the 26 letters like this, so even if you tried one key every second, you would need far longer than the age of the universe. Yet a scholar in ninth-century Baghdad explained how to read such a message with nothing more than pen and paper. How is that possible?
How can you read a cipher without knowing the key?
The method is called frequency analysis: you count how often each symbol appears in the secret message and compare the counts with how often letters appear in the language. It works against a substitution cipher, in which each letter of the alphabet is always replaced by the same other letter or symbol. Such a cipher changes what the letters look like, but not how often they appear. In English, e is by far the most common letter, at about 12.7 percent of all letters, followed by t and then a, so the most common symbol in a long English cipher probably stands for e.
One way to solve an encrypted message, if we know its language, is to find a different plaintext of the same language long enough to fill one sheet or so, and then we count the occurrences of each letter.
Here is a short message enciphered in this way, with cipher letters in capitals and our guessed plain letters in lower case.
DBBP DB GP PKB BGYP VGPB GP YBLBI. PKB VTGCOY XKGIVB PKBI, GIO PKB YPCBBP JY BDUPS FWC PBI DJITPBY.
We can break it in four steps:
- Count. The message has 77 letters, of which B appears 17 times, P 14 times and G 7 times, while no other letter appears more than 6 times. So we guess that B is e, P is t and G is a.
- Look for common words. The word PKB appears three times on its own. With our guesses it reads t?e, and the most common English word of that shape is “the”, so K is h.
- Fill in and test. The opening now reads “?eet ?e at the ea?t ?ate at ?e?e?”, which almost suggests itself: “meet me at the east gate at seven”. Each new word gives us more letters, such as D for m and Y for s, and each letter makes the other words easier.
- Check. The whole message reads: “Meet me at the east gate at seven. The guards change then, and the street is empty for ten minutes.” Every guess fits, so the key is right.
Counting did not give us the answer by itself. It gave us three good first guesses, and common words did the rest, so the real work is a cycle of guessing, testing whether the result makes sense, and going back when it produces nonsense.
What frequency analysis teaches you
A disguise that swaps one thing for another, one for one, hides what things look like but keeps the pattern of how often they occur. So whenever something is disguised, ask which pattern the disguise leaves unchanged.
- A queen’s letters. In 1586 Mary Queen of Scots, then a prisoner in England, wrote enciphered letters to Anthony Babington about a plot to kill Elizabeth I. Thomas Phelippes, the codebreaker of Elizabeth’s spymaster Francis Walsingham, counted the symbols and broke the cipher. Because Mary trusted her cipher, she wrote openly, and the letters convicted her; she was executed on 8 February 1587.
- Your own data. Suppose a company replaces every name in its email records with a code, but each person keeps the same code throughout. If everyone knows that one manager writes far more emails than anyone else, the most frequent code is probably hers. Replacing names one for one is a substitution cipher, and counting breaks it.
- Who wrote a text. The same counting works on words. In 1963 the statisticians Frederick Mosteller and David Wallace compared how often Alexander Hamilton and James Madison used small words such as “upon”, and concluded that Madison wrote the twelve disputed essays of the Federalist Papers. They weighed the counts with the reasoning described in Bayes’ Theorem, Explained, which also describes each guess in our example: a hypothesis that grows stronger with every letter that fits.
Where does frequency analysis fail?
The method has three limits. The first is the text itself. The frequency table is an average over long texts, so short or unusual texts break it, and Simon Singh notes that messages under about a hundred letters are very hard to decipher this way. Our example worked partly because it uses “the” three times. In 1969 the French writer Georges Perec published La Disparition, a whole novel without the letter e, and anyone who looked for e first in an enciphered copy would be misled.
The second is that codemakers fought back. They added homophones, several different symbols for one common letter, so that e no longer stands out in the counts. The cipher Mary used for her letters to the French ambassador in London had two symbols for common letters such as e and t. When George Lasry, Norbert Biermann and Satoshi Tomokiyo broke 57 of her lost letters in 2023, they needed a computer search as well as hand work.
Codemakers also used ciphers with several alphabets, such as the one Giovan Battista Bellaso described in 1553, which was later named after Blaise de Vigenère. A keyword decides which alphabet encrypts each letter, so one plain letter turns into different symbols. Charles Babbage broke this cipher privately in the 1850s, and Friedrich Kasiski published a method in 1863. Both used repeated patterns to find the length of the keyword, which splits the message into several simple substitution ciphers, and then counting works again.
The third limit matters most today. Many people think that any cipher falls to counting if you only have enough text. Modern ciphers, however, are designed so that their output looks like random noise, in which every symbol appears about equally often whatever the message says. Counting finds no pattern at all, so attackers look for weaknesses elsewhere, as What Is Public-Key Cryptography? shows.
Learn more
The earliest known description of frequency analysis comes from al-Kindi, a scholar who worked in Baghdad and died around 870. In A Manuscript on Deciphering Cryptographic Messages he explained how to count the letters of a sample text and match them to the symbols of a cipher. The manuscript was found again only in 1987, in an Ottoman archive in Istanbul. Singh suggests that the method grew out of Arab scholars’ close study of the Qur’an, for which they counted words and letters, and by the sixteenth century the cipher secretaries of European courts, Phelippes among them, used it routinely.
For the whole history of codes, from al-Kindi to Enigma, read “The Code Book” by Simon Singh: Summary and Review. His website also has a free tool for breaking a cipher yourself.
Quiz
3 questions · up to 3 points
Open a question and pick one answer. Only your first answer counts: +1 if it is right, −1 if it is wrong.
Why can counting symbols break a simple substitution cipher?
Show answer
Each letter always becomes the same symbol, so the symbols keep the letters' usual frequencies. The cipher changes what the letters look like but not how often they appear. A symbol that appears as often as e usually does is probably e.
In a substitution cipher with spaces, the symbol B is most common and the three-symbol word PKB appears three times. What is the best next guess?
Show answer
B is e, and PKB is the word 'the'. The most common symbol is probably e, and 'the' is the most common English word that ends in e. Each guess is then tested on the rest of the message.
Which message is hardest to break with frequency analysis alone?
Show answer
A 40-letter note in which each common letter has several different symbols. Short texts do not follow the usual frequencies, and several symbols per letter flatten the counts. Both remove what the method needs.
Your points are saved only in this browser for now. Accounts that keep them for good are on the way.
Continue learning: "The Code Book" by Simon Singh: Summary and Review →The takeaway
Frequency analysis breaks a substitution cipher by counting how often each symbol appears, because a cipher that always swaps a letter for the same symbol keeps that letter's frequency, so in English the most common symbol is probably e. Al-Kindi described the method in ninth-century Baghdad, and it convicted Mary Queen of Scots in 1586. It fails on very short or unusual texts and on ciphers that use several symbols per letter. Whenever something is disguised, ask which pattern the disguise leaves unchanged.
References
- Cracking the Substitution Cipher. Simon Singh, The Black Chamber
Singh's short guide to frequency analysis, with an interactive tool that lets you break a substitution cipher yourself.
- Arab Code Breakers. Simon Singh
How al-Kindi's treatise was found in an Istanbul archive, and why Arab scholars were the first to count letters.
- Al-Kindi. Peter Adamson, Stanford Encyclopedia of Philosophy, 2024
Who al-Kindi was: his life in ninth-century Baghdad and his work as the first philosopher writing in Arabic.
- Deciphering Mary Stuart's lost letters from 1578-1584. George Lasry, Norbert Biermann and Satoshi Tomokiyo, Cryptologia 47 (2), 101–202, 2023
The open-access paper on 57 enciphered letters of Mary Queen of Scots found in Paris and broken with computer search and hand work.
- Vigenère Cipher. Crypto Museum
How the cipher that defeated simple counting works, who really invented it, and how its repeating key gave it away.





