Lesson 5

Substitution Cipher: Crack a Real Puzzle

A stronger cipher where every letter gets its own secret replacement — and the classic way to break it

Not just a shift — a whole scramble

The Caesar cipher has one weakness: the shift is uniform. E always goes to the same letter, T goes 3 ahead of E, etc. So the shape of the frequencies stays the same.

A substitution cipher is stronger: every letter is assigned to a different letter completely at random.

PlainABCDEFGHIJKLM
CipherQWERTYUIOPASD

Now E might go to T, T might go to H, A might go to Q — all unrelated. There are 403,291,461,126,605,635,584,000,000 possible keys (that’s 26 factorial). You cannot try them all. Ever. In the lifetime of the universe.

So is it unbreakable?

No. Frequency analysis still wins.

How to crack one

Here’s the recipe:

  1. Count letters. The most common letter is probably E.
  2. Look at 3-letter words. A common one is probably THE — that gives you T, H, E all at once.
  3. Look at single-letter words. Those are A or I.
  4. Look at doubled letters (like XX). Common doubles are LL, EE, OO, SS.
  5. Fill in guesses and look for partial words. If you see TH_S a lot, the blank is probably I (THIS).
  6. Iterate. Correct mistakes as better guesses appear.

Crack this one

Below is a real substitution cipher. You have an interactive tool: click a cipher letter and type what you think the real letter is.

The quote is from a famous scientist, about curiosity and learning.

O IQUT CP DYTEOQS HQSTCH. O QZ PCSJ YQDDOPCQHTSJ EXKOPXD.

Try another one

ZIT ZIKTT TSTHIQFZL QZ FOUIZ TQZ ZQSS EGKF.

When substitution cipher DOES work

Substitution ciphers were good enough for:

They were broken around 800 AD by an Arab mathematician named al-Kindi who invented frequency analysis. Most cryptographers still didn’t catch on for another 700 years. That’s how powerful a simple new idea can be.

Practice

How many possible keys does a general substitution cipher have?

If a single letter appears by itself as a word in a ciphertext, it's probably...

Who invented frequency analysis?