Caesar cipher & ROT13
Shift-cipher encoder, decoder and a brute-force cracker for puzzles.
Brute-force cracker
All 26 shifts, most English-looking first.
| Shift | Plaintext |
|---|---|
| 0 | |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 |
How it works
A substitution cipher replaces each letter with another. The Caesar cipher shifts every letter by a fixed amount — Suetonius records Julius Caesar using a shift of three for military correspondence.
encrypt: E(x) = (x + k) mod 26
decrypt: D(x) = (x − k) mod 26 ROT13 is its own inverse
With a shift of 13 — exactly half the alphabet — encrypting twice returns the original. That is why one function serves both directions, and why Usenet adopted it for hiding spoilers and punchlines. It was never meant as encryption.
Atbash
An older scheme still: A becomes Z, B becomes Y, and so on. It appears in the Hebrew Bible, and like ROT13 it is self-inverse.
Vigenère was “le chiffre indéchiffrable”
Using a keyword to vary the shift letter by letter defeats simple frequency analysis, because the same plaintext letter encrypts differently depending on its position. It held its reputation for three centuries until Kasiski published a method for finding the key length from repeated patterns in the ciphertext — after which it fell quickly.
Why frequency analysis works
English letter frequencies are stable and lopsided: E is about 12% of all letters, T about 9%, and Z under 0.1%. Any cipher that maps each letter to exactly one other letter preserves those frequencies, so the pattern gives it away with only a paragraph of text.