Understanding ROT13 & Caesar
The world's simplest cipher.
A two-thousand-year-old trick for hiding a message just well enough that nobody reads it by accident.
The Caesar shift.
Julius Caesar, by Suetonius's account, wrote sensitive military messages by replacing each letter with the one three places ahead in the alphabet — A became D, B became E, and so on, wrapping around at Z. That single rule is a Caesar cipher: shift every letter by a fixed amount, leave non-letters alone. The shift is the key.
cipher(c) = (c + k) mod 26
Why thirteen is special.
Pick a shift of thirteen and the cipher becomes its own inverse: shift A by 13 to get N, shift N by 13 to get A. One function encodes and decodes. That symmetry is what made ROT13 a Usenet convention for hiding spoilers and punchlines — anyone could run the same routine to reveal them, no separate decode step required.
A worked round-trip.
Take the word Hello. Shift each letter by 13: H → U, e → r, l → y, l → y, o → b. The output is Uryyb. Run it through ROT13 again and you get Hello back. Punctuation and spaces don't move. A whole essay's worth of text can be obscured and revealed with the same eight-line function.
ROT13 round-trip
shift = 13; encode and decode are the same
Each letter walks halfway round the alphabet, then back.
Hello ↔ Uryyb
= Uryyb
Why it isn't security.
A Caesar cipher has at most twenty-five non-trivial keys. Trying all of them takes a fraction of a second. Even without trying anything, English text leaks — letter frequencies survive the shift, so the most common cipher letter is almost certainly E. Caesar ciphers were historically broken with a single frequency analysis. Today they're a teaching example, a fun puzzle, a way of hiding a spoiler from a casual scroll-by — not a way of keeping a secret.
What ROT13 is good for.
A surprising number of legitimate uses — none of them confidentiality. Hiding a riddle's answer below the riddle. Obscuring a venue's name from a search engine that's crawling a forum. Making a thirty-character string look unfamiliar to casual eyes. Treat it as the cipher equivalent of a brown paper bag: it stops the curious from reading what's inside, but it will not deter anyone determined.
The Vigenère bridge.
Generalise Caesar from one fixed shift to a sequence of shifts repeated as a key, and you get the Vigenère cipher — the next rung up the ladder. Vigenère stood unbroken for centuries because frequency analysis fails when the same letter encodes differently at different positions. It eventually fell to Kasiski's repetition method in the nineteenth century, which is when modern cryptography began.
Read next