Nepedia
Back to Discover
Advanced Reader
🔢

Caesar cipher

math Maturity 11-13 Next article →

A Caesar cipher is a method of encryption used to hide the meaning of a message. It is a type of monoalphabetic substitution cipher. In this system, every letter in a message is replaced by a different letter. This replacement happens by shifting the alphabet a fixed number of positions. This method is one of the simplest and most famous techniques in the field of cryptography.

Caesar cipher left shift of 3
Caesar cipher left shift of 3

To understand the mechanism, imagine two lines of alphabets aligned with one another. The first line contains the standard plain alphabet. The second line is the cipher alphabet, which is the plain alphabet shifted left or right by a specific number. This number is known as the shift parameter or the key. For example, a left shift of three replaces A with X, B with Y, and C with Z. To encrypt a message, a person looks up each letter in the plain line. They then write down the corresponding letter from the cipher line.

Confederate cipher disk
Confederate cipher disk

Deciphering is the process of reversing this transformation. If the message was encrypted with a left shift of three, it is decrypted with a right shift of three. This process can also be described using modular arithmetic. First, letters are transformed into numbers where A is 0 and Z is 25. The encryption of a letter $x$ by a shift $n$ is calculated as $(x + n) \pmod{26}$. To decrypt, the formula is $(x - n) \pmod{26}$. If the result falls outside the 0 to 25 range, 26 is added or subtracted to keep it within bounds.

This method is named after Julius Caesar. According to the Roman historian Suetonius, Caesar used a shift of three to protect messages of military significance. His nephew, Augustus, also used a cipher. Augustus used a right shift of one, but he did not wrap the alphabet around to the beginning. While Caesar is the most famous user, other substitution ciphers existed earlier. The grammarian Aulus Gellius even suggested that Caesar used more complicated systems beyond this simple shift.

Bust of Julius Caesar from History of the World (1902)
Bust of Julius Caesar from History of the World (1902)

Despite its history, the Caesar cipher is very easy to break in modern practice. One method is a brute force attack. Because there are only 25 possible shifts in the English alphabet, an attacker can simply try every single one. They look for the shift that produces meaningful text. Another method is frequency analysis. This relies on the fact that certain letters appear more often than others in a language.

English letter frequency percentages
English letter frequency percentages

By graphing the frequency of letters in the ciphertext, a person can match the pattern to the known distribution of the original language.

History shows that even when the cipher was known to be weak, it was still used. During World War I in 1915, the Russian army used it because it was easy for troops to master. However, German and Austrian cryptanalysts found it very easy to decrypt. In more recent history, the cipher has appeared in unexpected places. In 2006, the Mafia boss Bernardo Provenzano was captured partly because of a variation of the cipher. In 2011, a British Airways employee was convicted of terrorism offenses after using a Caesar cipher to discuss plots.

The Caesar cipher also serves as a building block for more advanced systems. The Vigenère cipher is a polyalphabetic substitution that uses a different Caesar shift for each position in the text. This shift is determined by a repeating keyword. If a keyword is as long as the message and is never reused, it becomes a one-time pad, which is impossible to break. Today, a version called ROT13 uses a shift of thirteen. It is often used on the internet to hide spoilers or joke punchlines, though it offers no real security.

615 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (4)
File:Caesar cipher left shift of 3.svg
Caesar cipher left shift of 3.svg
File:Bust of Julius Caesar from History of the World (1902).png
Bust of Julius Caesar from History of the...
File:Confederate cipher disk.jpg
Confederate cipher disk.jpg
File:English letter frequency percentages.png
English letter frequency percentages.png
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.