Code
Reading a text without its key: naming the cipher, peeling off encodings, counting letters, measuring an unknown script, breaking nomenclators, reading messages in depth, replaying the Enigma breaks, checking anagrams.
Frequency Analysis
Statistics for a ciphertext: letter frequencies beside those of six languages, bigrams and trigrams, Shannon entropy and chi-squared, the index of coincidence with Friedman’s estimate of the alphabets, Kasiski’s distances between repeated trigrams, and coincidences by lag and by column. Frequency analysis goes back to al-Kindi's ninth-century treatise; F. W. Kasiski published the repeat method in 1863; William Friedman introduced the index of coincidence in 1922.
Terms
History, how it works, how it was checked, limits
History
Al-Kindi’s ninth-century treatise is the earliest known description of frequency analysis. F. W. Kasiski published in Die Geheimschriften und die Dechiffrir-Kunst (1863) how repeats in a ciphertext give the length of a repeating key, and William Friedman introduced the index of coincidence in Riverbank Publication No. 22 (1922). Karl Pearson’s chi-squared (1900) measures how far counts lie from what is expected; Claude Shannon’s entropy (1948), how unpredictable the symbols are.
How it works
One text, six tabs; the statistics read the letters A–Z alone and name no cipher. Frequency draws the letters’ shares from A to Z against one of six languages’ and the pairs as a 26 × 26 map, and lists the 30 commonest bigrams and 20 commonest trigrams. Entropy gives the letters’ Shannon entropy in bits beside the language’s own and that of random letters, and chi-squared against the language. Coincidence sets the index on a gauge from random letters’ (1/26) to the language’s, with Friedman’s estimate of the number of alphabets. Kasiski takes key lengths 2–20 and ranks each by how many distances between repeated trigrams it divides beyond the one in k that chance gives it, and draws each repeat’s arc, gold where a length pressed divides it. Autocorrelation draws the matches at each lag up to 40 and the columns’ mean index for key lengths 2–20, against both levels, and ranks the lengths by how near it comes to the language’s. Counts gives words, characters as the reader sees them, letters, sentences and paragraphs.
How it was checked
The tests run the tool’s own functions. On the Declaration of Independence the index of coincidence is English’s own, unchanged by Atbash or by reversing the text, and the entropy is near Shannon’s 4.17 bits. Under Vigenère keys of 6, 8 and 12 letters Kasiski’s ranking puts the key length first; the columns and the lags find the 6 too, and in the figures the gold arcs are the 6’s hits and the gold key lengths the multiples of 3. The languages’ figures are checked against the n-gram statistics they come from.
The tests hold 53 checks of this tool; 2 rest on outside material:
- A print’s own example The Gold-Bug: the counts are Legrand’s table as Poe printed it, sign for sign (8 33, ; 26, 4 19 … ¶ 2, - and . 1); ( , which his table leaves out, 10
- A print’s own example The orders are named as Shannon 1948 names them on pp. 388–389, zero to third, and the fourth is said not to be his
Limits
The languages’ figures are counted from the books behind the solvers’ statistics, mostly older prose. Friedman’s estimate is rough on a short text and beyond a few alphabets. Kasiski needs repeats, and by columns a multiple of the true length reads as well. Chi-squared grows with the text, so it compares readings of one text. Accented letters are not counted.
- Ibrahim A. Al-Kadi, “Origins of Cryptology: The Arab Contributions”, Cryptologia 16 (2), 1992, pp. 97–126
- David Kahn, “Kasiski, Friedrich W.”, Neue Deutsche Biographie 11 (1977), p. 317 — on Die Geheimschriften und die Dechiffrir-Kunst (1863)
- William F. Friedman, The Index of Coincidence and Its Applications in Cryptography, Riverbank Publication No. 22 (Geneva, Illinois: Riverbank Laboratories, 1922)