Caesar cipher: a worked example
Let us encrypt and decrypt VENI VIDI VICI with key 3, letter by letter.
Let us take the phrase attributed to Caesar after the victory at Zela, VENI VIDI VICI, and encrypt it with key 3 using the 26-letter alphabet.
| Plain letter | Position (A=0) | Position + 3 | Cipher letter |
|---|---|---|---|
| V | 21 | 24 | Y |
| E | 4 | 7 | H |
| N | 13 | 16 | Q |
| I | 8 | 11 | L |
| D | 3 | 6 | G |
| C | 2 | 5 | F |
Applying the table to every letter we obtain:
VENI VIDI VICI → YHQL YLGL YLFLDecryption
The recipient receives YHQL YLGL YLFL and knows the key is 3: he moves every letter three positions back. Y returns to V, H to E, Q to N, L to I, and the message reappears.
Wrapping around the alphabet
What happens to the last letters? With key 3, X (position 23) would become position 26, which does not exist: you start again from the beginning, so X becomes A, Y becomes B and Z becomes C. In mathematics this operation is called modulo 26, explained in its own page.
Caesar cipher: the maths
Modular arithmetic, encryption and decryption formulas, key space: the Caesar cipher written as formulas.
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: how it works
Two alphabets side by side, one shifted: the mechanism of encryption and decryption step by step.
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.