Caesar cipher: how it works, how to decode it and why it is easy to break
The Caesar cipher replaces every letter with the letter a fixed number of places further along the alphabet, wrapping from Z back to A. With a shift of three, which Julius Caesar used according to Suetonius, A becomes D, B becomes E and HELLO becomes KHOOR. To decode, shift each letter back by the same number.

The Caesar cipher is the simplest code with a key, which makes it the classic first lesson in cryptography. This guide covers where it comes from, how to encode and decode a message by hand with a worked example, ROT13, the two ways to break it without the key, the Vigenère cipher that came next, and why none of this protects anything today. At the end, a free tool encodes, decodes and cracks it in the browser.
Key ideas
- Each letter moves a fixed number of places along the alphabet; the number of places is the key. With shift 3, A→D, B→E, X→A, Y→B, Z→C.
- According to Suetonius, Julius Caesar wrote confidential letters in this cipher with a shift of three; ROT13 is the same idea with a shift of 13.
- It is easy to break: the English alphabet allows only 25 shifts to try, and frequency analysis, first recorded by Al-Kindi in the 9th century, finds the shift from letter counts.
- The Vigenère cipher uses a different Caesar shift for each letter, set by a keyword, but it was broken in the 19th century; neither is secure today.
What is the Caesar cipher?
It is a substitution cipher in which every letter of the message is replaced by the letter a fixed number of positions later in the alphabet. That number, the shift, is the key. The same replacement applies to the whole message, which makes it a monoalphabetic substitution cipher. With the 26 letters of the English alphabet there are 25 useful shifts, since a shift of 26 puts every letter back where it was.
The cipher is named after Julius Caesar. The Roman historian Suetonius, in his Life of Julius Caesar, writes that when Caesar had something confidential to say in his letters, he wrote it in cipher, and that to read it one must substitute the fourth letter of the alphabet, D, for A, and so on with the others: a shift of three. Suetonius also notes that Augustus used a shift of one. How well the cipher protected Caesar's messages in his own time is unknown, because no record survives of how anyone then solved such ciphers.
In arithmetic terms, number the letters A = 0, B = 1 … Z = 25. To encrypt a letter x with shift n, compute (x + n) mod 26, the remainder after dividing by 26; to decrypt, compute (x − n) mod 26. For example, X is 23, and 23 + 3 = 26, which leaves remainder 0, so X becomes A. That remainder is what makes the alphabet wrap around like a ring.
How do you encode and decode a Caesar cipher?
Write out the alphabet, write it again shifted by the key underneath, and swap each letter for the one below it. To decode, read the table the other way round, which is the same as shifting back by the key.
For a shift of 3 the table is: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z above D E F G H I J K L M N O P Q R S T U V W X Y Z A B C. Encode MEET AT DAWN letter by letter: M→P, E→H, E→H, T→W, A→D, T→W, D→G, A→D, W→Z, N→Q. The result is PHHW DW GDZQ. Spaces and punctuation are usually left as they are, or removed so that word lengths give nothing away.
To decode PHHW, move each letter three places back: P→M, H→E, H→E, W→T, which spells MEET. Shifting back by 3 is the same as shifting forward by 23. A shift of 13, called ROT13, is special: 13 is half of 26, so the same operation both encodes and decodes, and HELLO becomes URYYB and back again. ROT13 is used to hide spoilers and joke punchlines, not to keep anything secret.
Why is the Caesar cipher so easy to break?
Because there are so few keys. With only 25 possible shifts, anyone can try them all, a brute-force attack, and keep the one line that reads as real language. By hand that takes minutes; a computer does it instantly. Encrypting twice does not help either, since a shift of A followed by a shift of B is just one shift of A + B.
The second method is frequency analysis. In English text the letters E and T are usually the most frequent, and Q and Z the least, and a Caesar shift moves that whole pattern along the alphabet without changing its shape. Count the letters of the ciphertext: if H is the most common, it probably stands for E, and the shift is 3. The earliest surviving descriptions of frequency analysis come from the 9th-century works of Al-Kindi in the Arab world. Very short texts can be ambiguous, since RIVER shifted by 9 becomes ARENA, but a sentence or two usually settles it.
The Vigenère cipher was the next step: it applies a different Caesar shift to each letter, set by a repeating keyword, with A meaning a shift of 0 and Z a shift of 25. With the key LEMON, ATTACK becomes LXFOPV: A + L = L, T + E = X, T + M = F, and so on. Giovan Battista Bellaso first described it in 1553; it was later misattributed to Blaise de Vigenère and earned the nickname “the indecipherable cipher”. Charles Babbage broke a variant as early as 1854 without publishing, and Friedrich Kasiski published a general attack in 1863. A keyword of one letter turns it back into a plain Caesar cipher.
Is the Caesar cipher secure today, and how can you try it?
No. Like every cipher that uses a single substitution alphabet, it offers essentially no security, and the Vigenère cipher has been breakable for more than 150 years. Today the Caesar cipher lives on in puzzles, in children's secret decoder rings and in ROT13; real messages and websites are protected by modern cryptography far beyond letter shifts. Its value is in teaching: keys, encryption and decryption, and why a small number of keys is fatal.
To try it, open the free Caesar cipher tool at VITON13 SCHOOL. Type a message, choose a shift and the tool encodes it; enter a ciphertext with the same shift and it decodes. A shift of 13 gives ROT13. The same tool runs the Vigenère cipher: enter a keyword instead of a shift to encode or decode with a different shift on every letter.
To crack a message without the key, use the cracking view: it lists all 25 shifts of the text at once, so the readable line stands out, and it shows the letter frequencies of the text, so you can compare them with the usual English pattern of E and T at the top. Use it to check the practice task below.
In everyday language
A Caesar cipher is a ring of letters turned a few clicks. Anyone who knows the number of clicks turns it back; anyone who does not can simply try all 25 positions.
Try it yourself
Encode your first name with a shift of 3 by hand, then enter the result in the Caesar cipher tool, decode it and look at the list of all 25 shifts.
Expected result
Your name moved three letters along, so ANNA becomes DQQD, and in the list of 25 shifts exactly one line that reads as your name.
Check your answer: Decode WKLV LV IXQ, which was encoded with a shift of 3.
THIS IS FUN. Move every letter three places back: W→T, K→H, L→I, V→S, then L→I, V→S, then I→F, X→U, Q→N.
Questions
What is the key of a Caesar cipher?
The key is the shift, the number of places each letter moves. In the English alphabet it can be 1 to 25; Caesar's own shift, according to Suetonius, was 3.
How do you decode a Caesar cipher without the key?
Try all 25 shifts and keep the one that reads as language, or count the letters: the most common one in an English ciphertext usually stands for E, which gives the shift.
Shift every letter by the key to encode and back by the key to decode; with only 25 keys, the Caesar cipher breaks by trying them all or by counting letters. Try it, then crack it, with the free VITON13 SCHOOL Caesar and Vigenère tool.
Sources and further reading
- Wikipedia: Caesar cipher ↗Sources checked:
- Suetonius, The Life of Julius Caesar, 56 (Loeb Classical Library, 1913), on LacusCurtius ↗Sources checked:
- Wikipedia: Vigenère cipher ↗Sources checked: