Repository navigation
Cryptanalysis
Last reviewed: 2026-10-02
Important
Historical and educational content. These attacks concern historical ciphers and do not provide a general method for breaking modern encryption. For protecting information, use the modern algorithms in algorithms.md and applied-crypto.md.
โ Building Your Own Alphabet ยท ๐ Classical Index ยท Security Relevance โ
Frequency analysis, n-grams, Kasiski examination, and the Index of Coincidence with a worked key-length attack.
On this page:
Monoalphabetic ciphers keep the "fingerprint" of the language. A commonly used approximate English frequency ranking is ETAOIN SHRDLU:
E 12.70% โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
T 9.06% โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
A 8.17% โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
O 7.51% โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
I 6.97% โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
N 6.75% โโโโโโโโโโโโโโโโโโโโโโโโโโโ
S 6.33% โโโโโโโโโโโโโโโโโโโโโโโโโ
H 6.09% โโโโโโโโโโโโโโโโโโโโโโโโ
R 5.99% โโโโโโโโโโโโโโโโโโโโโโโโ
D 4.25% โโโโโโโโโโโโโโโโโ
L 4.03% โโโโโโโโโโโโโโโโ
C 2.78% โโโโโโโโโโโ
U 2.76% โโโโโโโโโโโ
M 2.41% โโโโโโโโโโ
W 2.36% โโโโโโโโโ
F 2.23% โโโโโโโโโ
G 2.02% โโโโโโโโ
Y 1.97% โโโโโโโโ
P 1.93% โโโโโโโโ
B 1.29% โโโโโ
V 0.98% โโโโ
K 0.77% โโโ
J 0.15% โ
X 0.15% โ
Q 0.10%
Z 0.07%
- Frequency analysis: Count each ciphertext symbol and match the most common ones to E, T, A, O and so on, then refine.
-
Single-letter words: In English these are almost always
AorI. -
Doubled letters: Common doubles are
LL,EE,SS,OO,TT. -
N-grams: Common digraphs (
TH,HE,IN,ER,AN) and trigraphs (THE,AND,ING). -
Pattern words (crib dragging):
THAThas the pattern1-2-3-1,PEOPLEhas1-2-3-1-4-2. A ciphertext word with the same pattern is a candidate. - Brute force: A Caesar cipher has only 25 non-trivial keys, so try them all. A general substitution alphabet has 26! (about 4 ร 10ยฒโถ) keys, which is too many to brute-force, but frequency analysis and heuristic search can often recover sufficiently long natural-language messages. Runtime and success depend on the sample, language model, and search; short messages may remain ambiguous.
To break a Vigenรจre cipher, first find the key length L. Then the ciphertext splits into L columns, each a plain Caesar cipher that falls to frequency analysis.
Common words (like THE) sometimes line up with the same part of the repeating key and produce identical ciphertext sequences. Measure the distances between repeated sequences; the key length is likely a common factor of those distances.
William F. Friedman's Index of Coincidence (published 1922) measures how "rough" a letter distribution is: the probability that two letters drawn at random from the text are identical.
IC = ฮฃ nแตข(nแตข โ 1) / (N(N โ 1))
where nแตข is the count of each letter and N is the total number of letters.
| Text type | Expected IC |
|---|---|
| Uniformly random letters | 1/26 โ 0.0385 |
| English plaintext | โ 0.0667 |
| Sample English text in this section | 0.0738 |
Worked demo. A passage of English was encrypted with a 6-letter key. The ciphertext begins:
KBLHW KJMQL WKQNI PQVUQ IDEJV PTDSI UBDMX ZOMHP XNCAI OIRIM DMAZU LDTMK ...
The scan below splits the ciphertext into L columns for each guessed key length and averages the IC of the columns. Wrong guesses stay near random; the correct length (and its multiples) jumps toward English:
len 1 IC 0.0413 โโโโโโโโโโโโโโโโโโโโ
len 2 IC 0.0480 โโโโโโโโโโโโโโโโโโโโโโโ
len 3 IC 0.0522 โโโโโโโโโโโโโโโโโโโโโโโโโโ
len 4 IC 0.0502 โโโโโโโโโโโโโโโโโโโโโโโโโ
len 5 IC 0.0400 โโโโโโโโโโโโโโโโโโโ
len 6 IC 0.0761 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ key length
len 7 IC 0.0442 โโโโโโโโโโโโโโโโโโโโโโ
len 8 IC 0.0548 โโโโโโโโโโโโโโโโโโโโโโโโโโโ
len 9 IC 0.0494 โโโโโโโโโโโโโโโโโโโโโโโโ
len 10 IC 0.0471 โโโโโโโโโโโโโโโโโโโโโโโ
len 11 IC 0.0403 โโโโโโโโโโโโโโโโโโโโ
len 12 IC 0.0823 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
For a repeating Vigenรจre key, a candidate period L splits the text into candidate Caesar columns. A chi-squared score can rank shifts against reference language frequencies. Inspect multiple candidates and verify the complete message: short columns, accidental repeats, and multiples of the true period can mislead the analysis.
โ Building Your Own Alphabet ยท ๐ Classical Index ยท Security Relevance โ
- deciphering-workbook.md - a full workflow, attack assumptions, worked examples, and answer key
- ciphers.md - the ciphers being attacked
- cipher_toolkit.py - IC scan implementation
โฌ ๏ธ Back to Master Index | ๐ฏ Role Navigation | Legal Notice
๐ Source: Cryptography/Classical/cryptanalysis.md | โ๏ธ Suggest an edit | โฌ
๏ธ Back to Cryptography
- ๐บ๏ธ Browse by Topic
- ๐ All Repository Files
- ๐งญ Learning Paths
- ๐ Master Guide
- ๐ค Glossary
- โ๏ธ Legal & Disclaimer
๐ Foundations & Learning
๐ก๏ธ Defense & Investigations
- Incident Response
- Open Source Intelligence (OSINT)
- Reverse Engineering
- Operations Security (OPSEC)
- Compliance
โ๏ธ Platforms & Infrastructure
๐ก Hardware, Wireless & Field Projects
- PNWC Cyberdeck
- Hardware Testing
- Hardware Hacking
- Software-Defined Radio
- Wardriving
- uConsole
- Space Security
๐งฐ Assessment & Field Reference
๐ฆ Downloads & Project Resources
๐๏ธ Additional Topics