Security Ronin
Codebreakers

CryptLab 密碼實驗室

Make a cipher, then break one — the 1,200-year duel of codemakers and codebreakers, in your hand. Tap the ▸ sections to go deeper. No app, no signup.

Turn plain words into a cipher

Shift every letter along the alphabet and you have a Caesar cipher. Give it a keyword and it becomes Vigenère. Type below and watch it scramble. 打字睇住佢變密碼。

shift 3
How the Caesar cipher works

Pick a number — the shift. Slide every letter that far down the alphabet: with shift 3, A→D, B→E, and Z→C (it wraps around). The disk above is a cipher wheel: turn the inner ring by the shift and each outer letter points at what it becomes.

There are only 25 useful shifts, so a Caesar cipher is trivial to break — you can just try all of them. Its real lesson is the shape of every cipher that followed: a public method plus a secret key.

Kerckhoffs's Principle — secrecy lives in the key

In 1883 Auguste Kerckhoffs argued a cipher must stay secure even if the enemy knows exactly how it works — everything rests on the key. "Security through obscurity" (hiding the method) fails the moment the method leaks, and it always leaks.

Every modern cipher, including AES, follows this: the algorithm is public and studied worldwide; only the key is secret.

Vigenère — why it held for 300 years

A Caesar cipher uses one shift, so its letter frequencies survive and it falls to frequency analysis. Vigenère uses a keyword to change the shift on every letter — the same plaintext letter encrypts differently depending on position. That flattens the frequencies and blinded codebreakers from the 1500s until Charles Babbage and Friedrich Kasiski cracked it in the 1800s by finding the key's length.

Break it with frequency analysis

Every letter keeps its fingerprint. English leans hard on E, then T. Line the tallest bars up with English and type your guesses — the plaintext appears letter by letter. This message is a real substitution cipher. 逐個字母估,明文慢慢浮現。

Frequency in this messagetap a box under a bar, type the plaintext guess
English (typical)most common → E T A O I N S H R…
① Guided walkthrough — crack this exact message
  1. The ciphertext is already loaded above.
  2. Look at the bars. The tallest is the most common cipher letter — here it's R.
  3. In English the most common letter is E. Type E in the box under R and watch every R in the message turn into e.
  4. The second tallest is G. The second most common English letter is T — put T under G.
  5. Keep going down the English order (E T A O I N S H R…). Short common words fall out fast: gur → the, gb → to.
  6. When two bars are nearly equal — here B and N — you won't know which is O. Try one, read the result, swap if it's gibberish.
  7. Stop when it reads as English. Prefer Guess by frequency to auto-fill the ranking, then hand-fix the few it gets wrong.

The example letters (R, G, B, N) describe the first ciphertext. Pick any of the five above — the method is identical, only the mapping changes.

Why this works — Al-Kindi, 9th century

In Baghdad's House of Wisdom, Al-Kindi wrote the first known description of frequency analysis around 850 CE. His insight: a substitution cipher hides which symbol stands for a letter, but not how often it appears. Count the symbols, compare to a language's known letter frequencies, and the mapping unravels. One idea broke every simple cipher for the next 800 years.

The cost of a broken cipher — Mary, Queen of Scots

In 1586 Mary plotted against Elizabeth I in letters enciphered with a substitution "nomenclator." Walsingham's codebreaker Thomas Phelippes broke them with frequency analysis — and forged a postscript to expose her fellow plotters. The decrypts were read at her trial. She was executed in 1587. Same technique you're using now.

Why more ciphertext makes it easier

Letter frequencies are only reliable on average. In a short message the counts wobble, so the tallest bar isn't guaranteed to be E and near-ties (like B vs N here) are genuine coin-flips. The more ciphertext you intercept, the closer the counts settle to their true frequencies and the fewer guesses you need. It's the same reason a poll of 10,000 people beats a poll of 10.

Show the solution

The plaintext of the ciphertext you picked is:

Work out the letter mapping yourself, or hit Guess by frequency and fix the near-ties.