Caesar cipher: how it works
Two alphabets side by side, one shifted: the mechanism of encryption and decryption step by step.
The easiest way to understand the Caesar cipher is to write two alphabets one under the other, the second shifted forward by the number of positions chosen as the key.
| Plain | A | B | C | D | E | … | W | X | Y | Z |
|---|---|---|---|---|---|---|---|---|---|---|
| Cipher (key 3) | D | E | F | G | H | … | Z | A | B | C |
To encrypt, find each letter of the message in the first row and replace it with the one below. To decrypt, do the opposite: find the cipher letter in the second row and read the one above. Spaces, numbers and punctuation, in the classical version, stay unchanged or are removed.
- 01
Choose the key
A number from 1 to 25 that both parties know: for example 3.
- 02
Write the two alphabets
The second starts with the letter k positions after A.
- 03
Substitute
Each plaintext letter becomes the corresponding letter of the second alphabet.
- 04
Transmit
The recipient, who knows the key, repeats the procedure in reverse.
The cipher disk
Instead of rewriting the alphabets every time you can use two concentric disks with letters around the edge: turning the inner one by k positions, the substitution table is ready. It is the same principle as the cipher disk described in the Renaissance by Leon Battista Alberti, who however changed the disk’s position during the message — a far more powerful idea that paved the way for polyalphabetic ciphers.
Caesar cipher: a worked example
Let us encrypt and decrypt VENI VIDI VICI with key 3, letter by letter.
The pages of this topic
Back to the overviewCaesar cipher: the history
Suetonius, Julius Caesar, Augustus and letters written in Greek characters: what we really know about Roman ciphers.
Caesar cipher: the maths
Modular arithmetic, encryption and decryption formulas, key space: the Caesar cipher written as formulas.
Caesar cipher: how it is broken
Brute force, frequency analysis and known plaintext: three ways to break the Caesar cipher, each faster than the last.
Caesar cipher: today’s uses
ROT13, puzzles, teaching and obfuscation: where the Caesar cipher still turns up, and where it must never be used.
Caesar cipher: try it yourself
Three exercises to solve with pen and paper: encrypt, decrypt with the key, and break a message without the key.
Caesar cipher: frequently asked questions
Short answers to the most common doubts about the Caesar cipher and its variants.