Ciphers
Caesar cipher
Also found as shift cipher · Caesar shift · ROT cipher · ROT13
How it works
Give A–Z the values 0–25, then add the same shift k to each letter. Reduce the answer modulo 26 so the count wraps from Z back to A. Decryption subtracts k. In Decipher, case is kept and anything outside ASCII A–Z is left alone.Handbook of Applied Cryptography, chapter 7
Cᵢ = (Pᵢ + k) mod 26Pᵢ = (Cᵢ − k) mod 26Worked example
- Plaintext
ATTACK- Values
0 19 19 0 2 10- + 3 mod 26
3 22 22 3 5 13- Ciphertext
DWWDFN
What to look for
Caesar changes the letters but keeps every repeat, word length, doubled letter, and word shape. There are only 26 possible shifts, including no shift at all, so you can try every one. ROT13 uses shift 13; applying it twice returns the original text.
History and name
Suetonius reports that Julius Caesar replaced each letter with one a fixed distance away, and gives an example equivalent to a shift of three. The modern Caesar cipher extends this idea to any constant shift.Suetonius, Julius Caesar