Recent from talks
Nothing was collected or created yet.
Frequency analysis
View on Wikipedia
In cryptanalysis, frequency analysis (also known as counting letters) is the study of the frequency of letters or groups of letters in a ciphertext. The method is used as an aid to breaking classical ciphers.
Frequency analysis is based on the fact that, in any given stretch of written language, certain letters and combinations of letters occur with varying frequencies. Moreover, there is a characteristic distribution of letters that is roughly the same for almost all samples of that language. For instance, given a section of English language, E, T, A and O are the most common, while Z, Q, X and J are rare. Likewise, TH, ER, ON, and AN are the most common pairs of letters (termed bigrams or digraphs), and SS, EE, TT, and FF are the most common repeats.[1] The nonsense phrase etaoin shrdlu represents the 12 most frequent letters in typical English language text.
In some ciphers, such properties of the natural language plaintext are preserved in the ciphertext, and these patterns have the potential to be exploited in a ciphertext-only attack.
Frequency analysis for simple substitution ciphers
[edit]In a simple substitution cipher, each letter of the plaintext is replaced with another, and any particular letter in the plaintext will always be transformed into the same letter in the ciphertext. For instance, if all occurrences of the letter e turn into the letter X, a ciphertext message containing numerous instances of the letter X would suggest to a cryptanalyst that X represents e.
The basic use of frequency analysis is to first count the frequency of ciphertext letters and then associate guessed plaintext letters with them. More Xs in the ciphertext than anything else suggests that X corresponds to e in the plaintext, but this is not certain; t and a are also very common in English, so X might be either of them. It is unlikely to be a plaintext z or q, which are less common. Thus the cryptanalyst may need to try several combinations of mappings between ciphertext and plaintext letters.
More complex use of statistics can be conceived, such as considering counts of pairs of letters (bigrams), triplets (trigrams), and so on. This is done to provide more information to the cryptanalyst, for instance, Q and U nearly always occur together in that order in English, even though Q itself is rare.
An example
[edit]Suppose Eve has intercepted the cryptogram below, and it is known to be encrypted using a simple substitution cipher:
LIVITCSWPIYVEWHEVSRIQMXLEYVEOIEWHRXEXIPFEMVEWHKVSTYLXZIXLIKIIXPIJVSZEYPERRGERIM WQLMGLMXQERIWGPSRIHMXQEREKIETXMJTPRGEVEKEITREWHEXXLEXXMZITWAWSQWXSWEXTVEPMRXRSJ GSTVRIEYVIEXCVMUIMWERGMIWXMJMGCSMWXSJOMIQXLIVIQIVIXQSVSTWHKPEGARCSXRWIEVSWIIBXV IZMXFSJXLIKEGAEWHEPSWYSWIWIEVXLISXLIVXLIRGEPIRQIVIIBGIIHMWYPFLEVHEWHYPSRRFQMXLE PPXLIECCIEVEWGISJKTVWMRLIHYSPHXLIQIMYLXSJXLIMWRIGXQEROIVFVIZEVAEKPIEWHXEAMWYEPP XLMWYRMWXSGSWRMHIVEXMSWMGSTPHLEVHPFKPEZINTCMXIVJSVLMRSCMWMSWVIRCIGXMWYMX
For this example, uppercase letters are used to denote ciphertext, lowercase letters are used to denote plaintext (or guesses at such), and X~t is used to express a guess that ciphertext letter X represents the plaintext letter t.
Eve could use frequency analysis to help solve the message along the following lines: counts of the letters in the cryptogram show that I is the most common single letter,[2] XL most common bigram, and XLI is the most common trigram. e is the most common letter in the English language, th is the most common bigram, and the is the most common trigram. This strongly suggests that X~t, L~h and I~e. The second most common letter in the cryptogram is E; since the first and second most frequent letters in the English language, e and t are accounted for, Eve guesses that E~a, the third most frequent letter. Tentatively making these assumptions, the following partial decrypted message is obtained.
heVeTCSWPeYVaWHaVSReQMthaYVaOeaWHRtatePFaMVaWHKVSTYhtZetheKeetPeJVSZaYPaRRGaReM WQhMGhMtQaReWGPSReHMtQaRaKeaTtMJTPRGaVaKaeTRaWHatthattMZeTWAWSQWtSWatTVaPMRtRSJ GSTVReaYVeatCVMUeMWaRGMeWtMJMGCSMWtSJOMeQtheVeQeVetQSVSTWHKPaGARCStRWeaVSWeeBtV eZMtFSJtheKaGAaWHaPSWYSWeWeaVtheStheVtheRGaPeRQeVeeBGeeHMWYPFhaVHaWHYPSRRFQMtha PPtheaCCeaVaWGeSJKTVWMRheHYSPHtheQeMYhtSJtheMWReGtQaROeVFVeZaVAaKPeaWHtaAMWYaPP thMWYRMWtSGSWRMHeVatMSWMGSTPHhaVHPFKPaZeNTCMteVJSVhMRSCMWMSWVeRCeGtMWYMt
Using these initial guesses, Eve can spot patterns that confirm her choices, such as "that". Moreover, other patterns suggest further guesses. "Rtate" might be "state", which would mean R~s. Similarly "atthattMZe" could be guessed as "atthattime", yielding M~i and Z~m. Furthermore, "heVe" might be "here", giving V~r. Filling in these guesses, Eve gets:
hereTCSWPeYraWHarSseQithaYraOeaWHstatePFairaWHKrSTYhtmetheKeetPeJrSmaYPassGasei WQhiGhitQaseWGPSseHitQasaKeaTtiJTPsGaraKaeTsaWHatthattimeTWAWSQWtSWatTraPistsSJ GSTrseaYreatCriUeiWasGieWtiJiGCSiWtSJOieQthereQeretQSrSTWHKPaGAsCStsWearSWeeBtr emitFSJtheKaGAaWHaPSWYSWeWeartheStherthesGaPesQereeBGeeHiWYPFharHaWHYPSssFQitha PPtheaCCearaWGeSJKTrWisheHYSPHtheQeiYhtSJtheiWseGtQasOerFremarAaKPeaWHtaAiWYaPP thiWYsiWtSGSWsiHeratiSWiGSTPHharHPFKPameNTCiterJSrhisSCiWiSWresCeGtiWYit
In turn, these guesses suggest still others (for example, "remarA" could be "remark", implying A~k) and so on, and it is relatively straightforward to deduce the rest of the letters, eventually yielding the plaintext.
hereuponlegrandarosewithagraveandstatelyairandbroughtmethebeetlefromaglasscasei nwhichitwasencloseditwasabeautifulscarabaeusandatthattimeunknowntonaturalistsof courseagreatprizeinascientificpointofviewthereweretworoundblackspotsnearoneextr emityofthebackandalongoneneartheotherthescaleswereexceedinglyhardandglossywitha lltheappearanceofburnishedgoldtheweightoftheinsectwasveryremarkableandtakingall thingsintoconsiderationicouldhardlyblamejupiterforhisopinionrespectingit
At this point, it would be a good idea for Eve to insert spaces and punctuation:
Hereupon Legrand arose, with a grave and stately air, and brought me the beetle from a glass case in which it was enclosed. It was a beautiful scarabaeus, and, at that time, unknown to naturalists—of course a great prize in a scientific point of view. There were two round black spots near one extremity of the back, and a long one near the other. The scales were exceedingly hard and glossy, with all the appearance of burnished gold. The weight of the insect was very remarkable, and, taking all things into consideration, I could hardly blame Jupiter for his opinion respecting it.
In this example from "The Gold-Bug", Eve's guesses were all correct. This would not always be the case, however; the variation in statistics for individual plaintexts can mean that initial guesses are incorrect. It may be necessary to backtrack incorrect guesses or to analyze the available statistics in much more depth than the somewhat simplified justifications given in the above example.
It is possible that the plaintext does not exhibit the expected distribution of letter frequencies. Shorter messages are likely to show more variation. It is also possible to construct artificially skewed texts. For example, entire novels have been written that omit the letter e altogether — a form of literature known as a lipogram.
History and usage
[edit]

The first known recorded explanation of frequency analysis (indeed, of any kind of cryptanalysis) was given in the 9th century by Al-Kindi, an Arab polymath, in A Manuscript on Deciphering Cryptographic Messages.[3] It has been suggested that a close textual study of the Qur'an first brought to light that Arabic has a characteristic letter frequency.[4] Its use spread, and similar systems were widely used in European states by the time of the Renaissance. By 1474, Cicco Simonetta had written a manual on deciphering encryptions of Latin and Italian text.[5]
Several schemes were invented by cryptographers to defeat this weakness in simple substitution encryptions. These included:
- Homophonic substitution: Use of homophones — several alternatives to the most common letters in otherwise monoalphabetic substitution ciphers. For example, for English, both X and Y ciphertext might mean plaintext E.
- Polyalphabetic substitution, that is, the use of several alphabets — chosen in assorted, more or less devious, ways (Leone Alberti seems to have been the first to propose this); and
- Polygraphic substitution, schemes where pairs or triplets of plaintext letters are treated as units for substitution, rather than single letters, for example, the Playfair cipher invented by Charles Wheatstone in the mid-19th century.
A disadvantage of all these attempts to defeat frequency counting attacks is that it increases complication of both enciphering and deciphering, leading to mistakes. Famously, a British Foreign Secretary is said to have rejected the Playfair cipher because, even if school boys could cope successfully as Wheatstone and Playfair had shown, "our attachés could never learn it!".
The rotor machines of the first half of the 20th century (for example, the Enigma machine) were essentially immune to straightforward frequency analysis. However, other kinds of analysis ("attacks") successfully decoded messages from some of those machines.[6]
Frequency analysis requires only a basic understanding of the statistics of the plaintext language and some problem-solving skills, and, if performed by hand, tolerance for extensive letter bookkeeping. During World War II, both the British and the Americans recruited codebreakers by placing crossword puzzles in major newspapers and running contests for who could solve them the fastest. Several of the ciphers used by the Axis powers were breakable using frequency analysis, for example, some of the consular ciphers used by the Japanese. Mechanical methods of letter counting and statistical analysis (generally IBM card type machinery) were first used in World War II, possibly by the US Army's SIS. Today, the work of letter counting and analysis is done by computer software, which can carry out such analysis in seconds. With modern computing power, classical ciphers are unlikely to provide any real protection for confidential data.
Frequency analysis in fiction
[edit]
Frequency analysis has been described in fiction. Edgar Allan Poe's "The Gold-Bug" and Sir Arthur Conan Doyle's Sherlock Holmes tale "The Adventure of the Dancing Men" are examples of stories which describe the use of frequency analysis to attack simple substitution ciphers. The cipher in the Poe story is encrusted with several deception measures, but this is more a literary device than anything significant cryptographically.
See also
[edit]- Index of coincidence
- Topics in cryptography
- Zipf's law
- A Void, a novel by Georges Perec. The original French text is written without the letter e, as is the English translation. The Spanish version contains no a.
- Gadsby (novel), a novel by Ernest Vincent Wright. The novel is written as a lipogram, which does not include words that contain the letter E.
Further reading
[edit]- Helen Fouché Gaines, "Cryptanalysis", 1939, Dover. ISBN 0-486-20097-3.
- Abraham Sinkov, "Elementary Cryptanalysis: A Mathematical Approach", The Mathematical Association of America, 1966. ISBN 0-88385-622-0.
References
[edit]- ^ Singh, Simon. "The Black Chamber: Hints and Tips". Retrieved 26 October 2010.
- ^ "A worked example of the method from bill's "A security site.com"". Archived from the original on 2013-10-20. Retrieved 2012-12-31.
- ^ Ibrahim A. Al-Kadi "The origins of cryptology: The Arab contributions", Cryptologia, 16(2) (April 1992) pp. 97–126.
- ^ "In Our Time: Cryptography". BBC Radio 4. Retrieved 29 April 2012.
- ^ Kahn, David L. (1996). The codebreakers: the story of secret writing. New York: Scribner. ISBN 0-684-83130-9.
- ^ Kruh, Louis; Deavours, Cipher (January 2002). "The Commercial Enigma: Beginnings of Machine Cryptography". Cryptologia. 26 (1): 1–16. doi:10.1080/0161-110291890731. ISSN 0161-1194. S2CID 41446859.
External links
[edit]- Online frequency analysis tool
- Character and syllable frequencies of 41 languages and a portable tool to create frequency and syllable distributions
- Arabic letter frequency analysis
- Conditional probabilities for characters in English text
- Czech letter/bigram/trigram frequency
Frequency analysis
View on GrokipediaFundamentals
Definition and Basic Principles
Frequency analysis is a cryptographic technique that involves counting and comparing the relative frequencies of symbols, letters, or other units within a text or data stream to reveal underlying patterns or structures.[5] This method exploits the statistical regularities inherent in natural languages and other datasets, where certain elements occur more frequently than others, allowing analysts to infer relationships between ciphertext and plaintext without prior knowledge of the encoding key. At its core, frequency analysis relies on the principle that natural languages exhibit non-uniform distributions of characters, meaning letters do not appear with equal probability. For example, in English, the letters follow an approximate order of frequency remembered by the mnemonic "etaoin shrdlu," where 'e' is the most common, followed by 't', 'a', 'o', 'i', 'n', 's', 'h', 'r', 'd', 'l', and 'u'.[6] This uneven distribution arises from linguistic patterns, such as the prevalence of common words and grammatical structures. In cryptanalysis, observed frequencies in an encoded text are compared to these expected frequencies from the source language; significant matches or deviations help identify mappings or anomalies, as substitution ciphers preserve the original frequency profile despite obscuring individual symbols.[7] Mathematically, frequency analysis computes relative frequencies as proportions of occurrences. The relative frequency of a symbol is given by yielding values between 0 and 1, often expressed as percentages for interpretation. For instance, the letter 'e' in English text has a relative frequency of approximately 12.7%, making it a key indicator in analysis.[8] This foundational approach enables pattern recognition in encoded texts by highlighting consistencies between anticipated and actual distributions, serving as a prerequisite for more advanced cryptanalytic methods without requiring assumptions about specific encoding schemes.[9]Frequency Distributions in Natural Language
In natural languages, letter frequencies exhibit non-uniform distributions shaped by linguistic structures, with vowels and common consonants appearing far more often than rare ones. These patterns are derived from large corpora of written texts and provide a foundation for analyzing textual regularity. For instance, in English, the letter 'E' occurs approximately 12.02% of the time, followed by 'T' at 9.10% and 'A' at 8.12%, based on a sample of 40,000 words.[7] The following table summarizes the relative frequencies of letters in English, highlighting the dominance of a few characters:| Letter | Frequency (%) |
|---|---|
| E | 12.02 |
| T | 9.10 |
| A | 8.12 |
| O | 7.68 |
| I | 7.31 |
| N | 6.95 |
| S | 6.28 |
| R | 6.02 |
| H | 5.92 |
| D | 4.32 |
| L | 3.98 |
| U | 2.88 |
| C | 2.71 |
| M | 2.61 |
| F | 2.30 |
| Y | 2.11 |
| W | 2.09 |
| G | 2.03 |
| P | 1.82 |
| B | 1.49 |
| V | 1.11 |
| K | 0.69 |
| Q | 0.11 |
| X | 0.17 |
| J | 0.10 |
| Z | 0.07 |
Cryptanalytic Applications
Substitution Ciphers
A monoalphabetic substitution cipher encrypts plaintext by replacing each letter with a unique ciphertext letter according to a fixed permutation, thereby preserving the relative frequency distribution of letters from the original language.[17] This preservation occurs because the substitution is a one-to-one mapping, so the most frequent plaintext letters remain the most frequent in ciphertext, albeit under different symbols. To break such a cipher using frequency analysis, the cryptanalyst first tallies the frequencies of letters in the ciphertext and compares them to known plaintext distributions, such as English where 'E' appears approximately 12.7% of the time, followed by 'T' at 9.1%.[7] The most frequent ciphertext letter is then hypothesized to map to 'E', the next to 'T' or 'A', and so on, forming an initial partial key. This mapping is iteratively refined by examining digraphs (pairs of letters) and trigraphs, whose expected frequencies in English—such as 'TH' at about 2.7%—help resolve ambiguities and confirm substitutions.[18] Cryptanalysts employ tools like frequency charts to visualize these distributions and the index of coincidence (IC) to validate mappings, as the IC for a monoalphabetic ciphertext closely matches English's value of around 0.067, indicating non-random repetition patterns.[15] Additionally, the chi-squared test quantifies the goodness-of-fit between observed and expected frequencies in a proposed decryption: where is the observed count of the -th letter in the decrypted text, and is the expected count based on language frequencies; lower values suggest a better match to natural language.[19] This method succeeds against monoalphabetic ciphers because the fixed mapping retains detectable frequency patterns, but it fails against polyalphabetic ciphers, which use multiple substitutions to diffuse and flatten letter frequencies, approximating a uniform distribution.[20]Step-by-Step Example
Consider the short ciphertext "URFUA FOBRF MOBYL KFRBF KXDMF XFLBB ZFEUO ZFRKM FEXUO FRKUO LFUAF RBFYA MFURF PMCC", encrypted via a simple substitution cipher where each plaintext symbol (including spaces) is replaced by a unique ciphertext letter.[21] Begin by counting the occurrences of each letter to identify patterns matching expected English frequencies, where spaces and letters like E, T, and A appear most often.| Cipher Letter | Frequency |
|---|---|
| F | 16 |
| R | 7 |
| U | 7 |
| B | 6 |
| M | 5 |
| O | 5 |
| A | 3 |
| L | 3 |
| X | 3 |
| C | 2 |
| E | 2 |
| K | 2 |
| Y | 2 |
| Z | 2 |
| D | 1 |
| Cipher | Plain |
|---|---|
| F | (space) |
| R | T |
| U | I |
| Cipher | Plain |
|---|---|
| F | (space) |
| R | T |
| U | I |
| B | O |
| M | E |
| K | H |
| O | N |
| Y | U |
| L | G |
| Cipher | Plain |
|---|---|
| F | (space) |
| R | T |
| U | I |
| B | O |
| M | E |
| K | H |
| O | N |
| A | S |
| Y | U |
| L | G |
| X | A |
| Z | D |
| E | M |
| C | L |
| D | V |
| P | W |