Keyword substitution
Scramble the alphabet with a keyword and swap each letter for its partner.
- Family
- Monoalphabetic substitution
- Era
- Antiquity to the Renaissance
- Keys
- 26! ≈ 4 × 10²⁶ alphabets
A general substitution cipher replaces each letter with another according to any permutation of the alphabet. A keyword makes that permutation easy to remember and share.
With about 4 × 10²⁶ possible alphabets, trying every key is out of the question. Arab scholar al-Kindi still showed how to break it in the 9th century.
01 / 11 · Inside keyword substitution
A message to hide
This readable text is the plaintext. Encrypting turns it into ciphertext. Classical ciphers only touch letters.
The goal: whoever intercepts the ciphertext must not get back to these letters.
Playground
Build your own cipher alphabet
Pick a keyword: it opens the cipher alphabet, the rest of the alphabet follows. Then step through your message letter by letter.
Your input
Repeated letters are dropped; only A–Z count.
Zqqzbh zq rzvk
Encrypt
Open the alphabet with ZEBRAS
What happens
Write the keyword first, then every letter not used yet, in order. Each plain letter gets the cipher letter written under it.
On your values
ZEBRAS + CDFGHIJKLMNOPQTUVWXY
A→Z B→E C→B …
Why it matters
Any shuffle of the alphabet is a key: 26! ≈ 4 × 10²⁶ of them, far too many to try. Yet each letter always gets the same partner, so the letter frequencies of the language pass straight through (see below).
Spaces, digits and punctuation pass through unchanged; accents are dropped.
Start
← → to step · space to playHow it’s broken
Frequency analysis: count, rank, match
26! keys are too many to try, so the attacker counts letters instead. Rank the ciphertext’s letters by count and line them up with English’s ranking: the top guesses are often right, and word patterns (THE, AND…) fix the rest. Al-Kindi described the method in the 9th century.
Ciphertext with the 7 ranking guesses filled in (· = not guessed yet)
ETTEAO ET NESI
| cipher | count | guess | actual |
|---|---|---|---|
| Z | 33.3% | E | A ✗ |
| Q | 25.0% | T | T ✓ |
| B | 8.3% | A | C ✗ |
| H | 8.3% | O | K ✗ |
| K | 8.3% | I | N ✗ |
| R | 8.3% | N | D ✗ |
| V | 8.3% | S | W ✗ |
1 of 7 guesses right from counting alone.
Short texts can fool the statistics: the longer the ciphertext, the surer the attack. Try the long-text preset.
How it works
- 1Write the keyword's letters, dropping any that repeat.
- 2Append the rest of the alphabet in order, skipping letters already used. This is the cipher alphabet.
- 3Replace each plaintext letter with the cipher letter in the same position.
- 4To decrypt, find the letter in the cipher alphabet and read the plain letter above it.
How it is broken
Frequency analysis: in English, E, T and A are the most common letters, and their substitutes stand out in any ciphertext of reasonable length.
Common short words and letter pairs (THE, AND, TH, HE) give away more of the mapping, one guess at a time.
Keyword alphabets add another weakness: the end of the cipher alphabet is often left almost in order.