The Caesar cipher: shifting letters to hide a message
The most famous cipher of antiquity: how the three-letter shift works, why it breaks in seconds and what it still teaches today.
The Caesar cipher is a substitution cipher in which every letter of the message is replaced by the letter a fixed number of positions further along the alphabet. With a shift of three, A becomes D, B becomes E, and so on to the end of the alphabet, where you start again from the beginning: X becomes A, Y becomes B, Z becomes C.
It bears the name of Julius Caesar because the historian Suetonius tells us the general used it in confidential correspondence. It is extremely simple, and that is precisely why it has become the first example in every cryptography lesson: it contains in miniature all the fundamental concepts — plaintext, ciphertext, algorithm, key — and shows clearly why a key that is too small protects nothing.
The ingredients of every cipher
- Plaintext
- The original, readable message: VENI VIDI VICI.
- Algorithm
- The general rule: move every letter forward in the alphabet.
- Key
- The secret detail that makes the encryption unique: by how many positions to shift.
- Ciphertext
- The result to transmit: with key 3, YHQL YLGL YLFL.
The distinction between algorithm and key is the most important idea the Caesar cipher hands down to modern cryptography: the method may be known to everyone, and security must depend only on the key. Here the key has just 25 useful values, and that is its fatal limit.
The pages of this topic cover the history, the step-by-step mechanism, a worked example, the mathematics, the attacks, today’s uses and an exercise to solve by hand. You can also try encryption with the interactive wheel on the home page.
The pages of this topic
Caesar 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: a worked example
Let us encrypt and decrypt VENI VIDI VICI with key 3, letter by letter.
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.