Caesar cipher
Adapted from Wikipedia · Discoverer experience
A Caesar cipher is one of the simplest and most widely known encryption techniques used in cryptography. It is a special kind of code called a substitution cipher, where each letter in a message, called the plaintext, is changed to another letter by moving a fixed number of places along the alphabet. For example, if you move three places to the left, the letter D would become A, and E would become B.
This method is named after Julius Caesar, the famous Roman leader, who used it to keep his private messages secret. Even though it seems clever, the Caesar cipher is very easy to break because there are only a few possible ways to shift the letters.
Today, the idea behind the Caesar cipher is still used in more complicated coding systems, like the Vigenère cipher and the ROT13 system. However, because it is so simple, the Caesar cipher does not provide real security for important information in the modern world. It is mostly used to show how basic codes work.
Example
A Caesar cipher is a simple way to hide messages by shifting each letter in the alphabet by a certain number of places. For example, with a left shift of three places, the letter "T" becomes "Q", "H" becomes "E", and so on. To read the hidden message, you shift the letters back in the opposite direction.
This type of cipher can also be explained using numbers. Each letter is turned into a number, with A equal to 0, B equal to 1, and so on up to Z equal to 25. The encryption formula adds the shift number to the letter's number, while decryption subtracts it. Both use a process called "modulo" to keep the result within the range of the alphabet.
Main article: modulo operation
The Caesar cipher is a kind of substitution cipher where the same shift is used for every letter in the message, making it a monoalphabetic substitution. This is different from a polyalphabetic substitution.
Main articles: monoalphabetic substitution, polyalphabetic substitution
History and usage
See also: History of cryptography
The Caesar cipher is named for Julius Caesar, who used it with a shift of three letters to protect important military messages. For example, the letter A would become D. His nephew, Augustus, also used a similar method but with a different shift.
Later, the Caesar cipher appeared in many places, from ancient Hebrew texts to newspapers in the 1800s. Even in modern times, it is used in simple toys like secret decoder rings. A version called ROT13 shifts letters by thirteen and is often used to hide jokes or spoilers online.
Breaking the cipher
The Caesar cipher is simple to solve because there are only 25 possible ways to shift the letters in the alphabet. Someone trying to break the code can try each shift one by one until they find the one that makes sense in the original language. For example, the ciphertext "exxegoexsrgi" becomes "attackatonce" when shifted four places, which clearly makes sense as English.
Another way to solve the cipher is by looking at how often each letter appears in the message. By comparing these patterns to what is normally expected in the language, the correct shift can usually be found. Even just a few letters of the coded message are often enough to figure out the whole thing. Repeating the encryption multiple times doesn’t make the cipher harder to break, as it simply adds up to one overall shift.
| Decryption shift | Candidate plaintext |
|---|---|
| 0 | exxegoexsrgi |
| 1 | dwwdfndwrqfh |
| 2 | cvvcemcvqpeg |
| 3 | buubdlbupodf |
| 4 | attackatonce |
| 5 | zsszbjzsnmbd |
| 6 | yrryaiyrmlac |
| ... | |
| 23 | haahjrhavujl |
| 24 | gzzgiqgzutik |
| 25 | fyyfhpfytshj |
This article is a child-friendly adaptation of the Wikipedia article on Caesar cipher, available under CC BY-SA 4.0.
Images from Wikimedia Commons. Tap any image to view credits and license.
Safekipedia