Caesar cipher
Every letter moves the same number of places along the alphabet. Only 25 keys change anything, so you can try them all, one after another.
- Made
- 1st c. BC — Julius Caesar, according to Suetonius
- Broken
- no date or name — trying 25 keys is enough
- How it works
- every letter shifted by the same number of places in the alphabet
- Today
- XOR and the one-time pad
- Sources
Letters shifted by the key
The Caesar cipher replaces every letter with the letter a fixed number of places further on in the alphabet. That number is the key. On the disk, the outer ring is the plaintext and the inner ring the ciphertext: turning the inner ring by the key puts each letter’s replacement under it. Decryption turns it back by the same key.
Suetonius gives only the rule, with no device (see Context), so the disk is this site’s aid. It has the 26 letters of today’s Latin alphabet and wraps from Z back to A.
Cipher disk
The disk has the 26 letters of today’s Latin alphabet. Polish letters lose their marks (ś → S); digits and other characters pass through unchanged.
Key 3: each letter is replaced by the letter 3 further on in the alphabet (A → D, B → E); after Z you count on from A.
Pplaintext ATTACK AT DAWN
Cciphertext DWWDFN DW GDZQ
25 keys, one by one
The key is a number from 0 to 25, and 0 changes nothing, so 25 keys are left to try. The attacker does not need the key: they shift the ciphertext back by 1, by 2, by 3 and read the result each time. Only one shift gives a sentence that makes sense.
All the keys the sender could have chosen are the key space. Here it fits in a table of 25 rows, so the cipher falls without any trick. The counter below keeps track of the keys tried.
Try every key
Ciphertext intercepted. Move the key and look for a sentence that makes sense.
| Key | Text shifted back |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 |
What Suetonius writes
Julius Caesar lived from 100 to 44 BC (Smith, Dictionary of Greek and Roman Biography). We know of his cipher from Suetonius’s Lives of the Caesars. Suetonius writes that in Caesar’s letters, whatever was to stay secret was written in cipher, and says how to read it.
Exstant et ad Ciceronem, item ad familiares domesticis de rebus, in quibus, si qua occultius perferenda erant, per notas scripsit, id est sic structo litterarum ordine, ut nullum verbum effici posset; quae si qui investigare et persequi velit, quartam elementorum litteram, id est D pro A et perinde reliquas commutet.
There are also letters of his to Cicero, as well as to his intimates on private affairs, and in the latter, if he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out. If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others. (Loeb Classical Library translation, 1913)
D is the fourth letter of the alphabet, so in the ciphertext every letter stands three places further on than in the plaintext: A becomes D, B becomes E. That is key 3 on the disk above.
In the life of Augustus, Suetonius describes the same idea with key 1:
Quotiens autem per notas scribit, B pro A, C pro B ac deinceps eadem ratione sequentis litteras ponit; pro X autem duplex A.
Whenever he wrote in cipher, he wrote B for A, C for B, and the rest of the letters on the same principle, using AA for X. (Loeb Classical Library translation, 1913)
So for X Augustus wrote AA. At key 1, the disk in this replica turns X into Y and Z into A.
The same search today
The key is one of 25 numbers. Trying them all gives 25 texts, and only one makes sense: the real one.
A one-time pad has a random key as long as the message. The same search gives every text of that length, so there is no telling which one was real.
See it in the station: XOR and the one-time pad →