Classical Ciphers
Caesar, Vigenère, ROT13, and substitution — the ciphers CTF beginners meet first and how to crack them all.
Why classics appear in CTFs
Organisers use classical ciphers as accessible entry points: the math is pre-computer, the ciphertext is printable text, and the “aha” moment is satisfying. Recognising the cipher family is half the work.
Caesar / ROT13
The Caesar cipher shifts every letter by a fixed amount. ROT13 is Caesar with a shift of 13 — applying it twice gives back the original.
KHOOR ZRUOG → shift −3 → HELLO WORLD
If the flag looks like naq gur synt vf..., it’s ROT13 — paste it in
CyberChef’s ROT13 operation and you’re done.
Brute-forcing: only 25 shifts to try. CyberChef’s ROT13 Brute Force or a simple Python loop:
ct = "KHOOR ZRUOG"
for shift in range(26):
print(shift, ''.join(chr((ord(c) - 65 - shift) % 26 + 65) if c.isupper() else c for c in ct))
Vigenère
A polyalphabetic substitution: a keyword repeats over the plaintext and each letter gets a different Caesar shift. The key signature is repeating patterns separated by the key length.
Attack — Kasiski / Index of Coincidence:
- Find repeated sequences in the ciphertext; their distance is a multiple of the key length.
- Try key lengths 2–20; pick the one whose IC is closest to English (~0.065).
- For each key position, collect every n-th character and frequency-analyse.
CyberChef’s Vigenère Decode accepts the key once you’ve recovered it. dcode.fr has an auto-solve.
Monoalphabetic substitution
Every letter maps to a fixed different letter. No key — just 26 unknowns. The attack is frequency analysis:
- English frequency order:
E T A O I N S H R D L C U M W F G Y P B V K J X Q Z - Map the most-frequent ciphertext letter to
E, next toT, etc., then tweak by hand using bigrams (TH,HE,IN).
quipqiup.com automates this with near-perfect accuracy.
Recognising the cipher family
| Clue | Likely cipher |
|---|---|
| Only letters, uniform distribution | Substitution or Caesar |
Two-character alphabet (. -) |
Morse |
| Base64-looking but offset | Vigenère or XOR |
| Repeating short word boundaries | Vigenère |
Flag wrapped as ROT13(...) |
Apply ROT13 once |
CyberChef workflow
Paste ciphertext → Magic operation → enable “Intensive Mode” → CyberChef will try dozens of operations and flag likely decryptions automatically.