Cryptography Overview

Cryptography is the practice of disguising information so that only the intended reader can understand it. Every classical cipher is based on one of two main ideas:

This page explains the most well-known ciphers in plain language and shows you how to break them yourself using The Cipher Lab’s interactive Tools and Cipher Breaker.

💡 Tip: To start analysing any cipher, run your text through the Frequency Analyzer — it highlights the most common letters, which often exposes the key.
Each cipher below has a compact explanation, plus a Read more dropdown with a deeper “how it works / how to break / quick visual”.

Substitution Cipher

A substitution cipher replaces every letter in the alphabet with another. The mapping stays the same for the entire message — that consistency is exactly what you exploit to break it.

Plaintext: HELLO WORLD Ciphertext: QEBBY TBOBD

How to Break It (fast)

Use frequency + word patterns. In English, E/T/A/O/I are common. If spaces are kept, word lengths and repeats give huge clues.

Read more how it works • what leaks • best workflow

What leaks (weakness)

  • Letter frequency: ciphertext inherits English distribution.
  • Repeats: double letters (LL, EE) and repeated short words.
  • Word shapes: patterns like _H_ can hint “THE”.

Practical breaking steps

  • Run frequency: guess E/T/A/O/I candidates.
  • Find “THE”, “AND”, “OF”, “TO” using patterns.
  • Lock confirmed letters, then iterate (it snowballs).
Visual mapping idea (example)
A fixed alphabet swap for the whole message.
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: QWERTYUIOPASDFGHJKLZXCVBNM
If you get even 6–10 letters right, the rest becomes much easier. Keep a running mapping and don’t “un-guess” without a reason.

Caesar Cipher

The Caesar cipher shifts every letter by the same number of positions in the alphabet. After Z, it wraps back to A.

Shift: 3 Plaintext: HELLO → Ciphertext: KHOOR

How to Break It (fast)

There are only 25 possible shifts. Brute force them and pick the one that produces readable English.

Read more formula • wrap-around • quick checks

How it works (math)

Convert letters to numbers A=0..Z=25. Encrypt: (x + s) mod 26. Decrypt: (x − s) mod 26.

Fast sanity checks

  • Common hits: “THE”, “AND”, “ING”.
  • ROT13 is special: shift 13 decrypts itself.
Shift wheel (+3)
Just a rotated alphabet.
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Shift+3: DEFGHIJKLMNOPQRSTUVWXYZABC

Vigenère Cipher

Vigenère uses a keyword to apply multiple Caesar shifts. The shift changes through the message based on the key letters.

Key: KEY Plaintext: ATTACKATDAWN Ciphertext: KXRKGIKXREQF

How to Break It (fast)

Find the key length first (Kasiski / IOC), then solve each column as a Caesar cipher.

Read more Kasiski • IOC • per-column frequency

Key length tools

  • Kasiski: repeated ciphertext chunks → distances share factors ≈ key length.
  • IOC: split into k columns; the correct k makes columns look “English-like”.

Then solve

  • For each column, run frequency like Caesar.
  • Combine shifts → keyword.
  • Decrypt and refine (errors stand out quickly).
Column split idea k=3
Every 3rd character goes into the same bucket.
Cipher: K X R K G I K X R E Q F Col 1: K K K E Col 2: X G X Q Col 3: R I R F
Once you know the key length, Vigenère becomes several smaller Caesar ciphers — one for each key position.

Affine Cipher

Affine encrypts letters using multiplication and addition mod 26. It’s stronger than Caesar, but still small enough to brute force.

Key: (a=5, b=8) Plaintext: AFFINE → Ciphertext: IHHWVCS

How to Break It (fast)

Brute force all valid (a,b) pairs and score the outputs for English.

Read more formula • valid a values • decryption

Formula

With A=0..Z=25: E(x)=(a·x+b) mod 26. Decrypt: D(y)=a⁻¹·(y−b) mod 26.

Valid keys

You need gcd(a,26)=1 so an inverse exists. Valid a values: 1,3,5,7,9,11,15,17,19,21,23,25. b can be 0–25.

Breaking

  • Try all valid a and all b.
  • Pick the best-looking plaintext.
Affine intuition linear
Multiply stretches the alphabet; add shifts it.
E(x)=(a·x+b) mod 26 a=5,b=8: A(0)->I(8) B(1)->N(13) C(2)->S(18)

Playfair Cipher

Playfair encrypts pairs of letters using a 5×5 key square (I/J combined). It hides single-letter frequencies — but digraph patterns leak.

Key: MONARCHY HELLO → GYIYQ

How to Break It (fast)

Use digraph frequency + cribs. For serious cracking, heuristic search (hill-climbing) is common.

Read more key square • rules • breaking strategy

Rules

  • Same row: take letters to the right (wrap).
  • Same column: take letters below (wrap).
  • Rectangle: swap corners (same row, other column).

Plaintext prep

  • Split into pairs.
  • If a pair repeats (LL), insert filler (often X): HE LX LO.

Breaking

  • Look at digraphs like TH/HE/IN/ER.
  • Try cribs and test quickly with tools.
Example 5×5 square (I/J)
Built from keyword, then remaining letters.
M O N A R C H Y B D E F G I K L P Q S T U V W X Z

Hill Cipher

The Hill cipher encrypts blocks of letters using matrix multiplication mod 26. It’s a classical cipher that directly uses linear algebra.

Key Matrix: [[3,3],[2,5]] Plaintext (HI) → Ciphertext (RC)

How to Break It (fast)

If you know matching plaintext/ciphertext blocks, you can solve for the matrix. Otherwise, brute force only works for tiny keys.

Read more invertibility • block size • key recovery

How it works

  • Choose block size n (e.g. 2).
  • Convert letters to numbers.
  • Compute C = K·P mod 26.

Key requirement

K must be invertible mod 26 (det(K) must have an inverse mod 26).

Breaking

  • Known plaintext: enough pairs → solve for K.
  • Otherwise: use automated search with strong scoring.
Block math n=2
Two letters become a vector, multiplied by the matrix.
P=[H,I]=[7,8] K=[[3,3],[2,5]] C=K·P mod 26

Autokey Cipher

Autokey is a Vigenère variant where the key extends using the plaintext itself, reducing repetition and hiding key-length patterns.

Key: KEY → Extended Key: KEYATTACK Plaintext: ATTACKATDAWN Ciphertext: KXRKGIQXREQF

How to Break It (fast)

Use cribs (“DEAR”, “ATTACK”, known headers). Once a chunk of plaintext is guessed, the key stream can unravel.

Read more why harder • where it leaks • breaking

What changes vs Vigenère

After the initial keyword, the key becomes the plaintext stream. That kills repeating-key repeats.

Breaking

  • Guess a plausible plaintext fragment (crib).
  • Use it to derive key letters for that region.
  • Because the key becomes plaintext, recovering plaintext grows the key too.
Key grows concept
Key stream after the seed keyword is plaintext.
Key: K E Y A T T A C K ... Plaintext: A T T A C K A T D A W N

Transposition Ciphers

Transposition ciphers rearrange letters instead of replacing them. Letter frequency stays roughly English, but words are scrambled.

Key: ZEBRAS Plaintext: WEAREDISCOVEREDRUN Ciphertext: EVLNEACDTKESEAQROFO

How to Break It (fast)

Try likely widths (column counts), look for word fragments, and use cribs if you suspect certain words appear.

Read more spotting it • width testing • cribs

How to spot

  • Frequency looks “normal” but nothing decodes like substitution.
  • Vowels appear at normal rates.

Breaking workflow

  • Test widths (2..20 etc) and score outputs for English.
  • For columnar: test short keys or use heuristic search for longer keys.
  • Cribs: try placing a suspected word into a grid.
Grid concept idea
Fill row-wise, read column-wise (often by key order).
WEARE DISCO VERED RUNXX (padding)

Bacon Cipher

Bacon’s cipher hides letters as patterns of As and Bs — often disguised using two text styles (case, font, bold/normal).

AABAA AABAB ABBAB → HELLO

How to Break It (fast)

Identify the two styles, map them to A/B, group into 5s, and decode.

Read more carrier text • two styles • decode steps

Decoding steps

  • Pick a rule: Style 1 = A, Style 2 = B.
  • Read off the A/B stream.
  • Group into chunks of 5.
  • Convert each chunk into a letter (variant-dependent).

Common gotcha

Copy/paste often destroys formatting. If styles disappear, use screenshots or inspect the HTML.

Two-style idea A/B
Upper/lower (or bold/normal) becomes bits.
a A b a a -> A B A A A Group by 5 -> decode

Morse & Enigma

Morse is an encoding (no secret key), while Enigma is a rotor-based cipher that changes substitution with every key press.

HELLO → •••• · ·−·· ·−·· −−−
Read more morse basics • enigma concept • breaking

Morse basics

  • Not a cipher: it’s reversible without a secret.
  • Spacing matters: letter gaps vs word gaps.

Enigma overview

Enigma uses rotors + plugboard. The “key” is rotor order, ring settings, start positions, and plugboard pairs.

How it was broken (high level)

  • Cribs (guessed plaintext fragments).
  • Constraints + automation (bombes).
Encoding vs cipher key?
Quick way to tell what kind of “mystery text” you have.
Encoding: reversible without secret Cipher: reversible only with key
If someone says “Morse cipher”, they usually mean “Morse encoding” — there’s no key to crack, just decoding.