What is a Keyed Substitution Cipher?
A keyed substitution cipher uses a keyword or phrase to create a custom substitution alphabet. Unlike a simple Caesar cipher which shifts the entire alphabet, keyed substitution creates a completely scrambled alphabet based on your keyword.
How It Works
The cipher alphabet is created in three steps:
- Remove duplicates: Take your keyword and remove any duplicate letters
- Add remaining letters: Append all unused letters of the alphabet in order
- Substitute: Map each normal letter to its corresponding cipher letter
Example
Keyword: MATRIX
Process:
- Remove duplicates: MATRIX (no duplicates)
- Add remaining letters: MATRIXBCDEFGHJKLOPQSUVWYZ
Result:
Example Encryption:
- HELLO → CXGGJ
- A→M, B→A, C→T, D→R, E→I, etc.
Key Features
- Keyword-based: Security depends on keeping the keyword secret
- Monoalphabetic: Each letter always maps to the same cipher letter
- Reversible: Use the same key to decrypt
- Better than Caesar: 403,291,461,126,605,635,584,000,000 possible keys!
History
Substitution ciphers have been used since ancient times. Julius Caesar used a simple version, but keyed substitution ciphers became popular in medieval times for diplomatic communications. Mary, Queen of Scots famously used a substitution cipher in her letters, which was eventually broken and used as evidence against her.
Breaking Keyed Substitution
Despite having many possible keys, keyed substitution ciphers can be broken using:
- Frequency Analysis: E, T, A, O, I, N are the most common letters in English
- Pattern Recognition: Common words like THE, AND, OF reveal patterns
- Digram/Trigram Analysis: Letter pairs (TH, HE, IN) and triplets (THE, AND)
- Known Plaintext: If part of the message is known, the key can be derived
Modern Uses
While not secure for modern cryptography, keyed substitution is used for:
- Teaching classical cryptanalysis techniques
- Puzzle games and escape rooms
- Understanding frequency analysis
- Historical cipher reconstruction
Tips for Stronger Keys
- Use longer keywords (20+ characters)
- Combine multiple words: "THEREBELSARECOMING"
- Use memorable phrases that others won't guess
- Avoid common words or phrases