Julius Caesar shifted letters by 3. Suetonius documented it around 121 CE. Learn the exact math, the ROT13 self-inverse property, and how brute force and frequency analysis break it in seconds.
In 50 BCE, Julius Caesar sent military dispatches that, if intercepted, would read as nonsense. A messenger carrying the plaintext "ATTACK AT DAWN" held the literal battle plan. Caesar's solution was to shift every letter forward by three positions in the alphabet, so that message became DWWDFN DW GDZQ. We know this not from speculation but from a primary source: the Roman historian Suetonius documented the exact shift of 3 in The Twelve Caesars around 121 CE, in the chapter on Gaius Julius Caesar (section 56).
The cipher worked against an illiterate courier who might be robbed on the road. Against anyone who knew the Latin alphabet and had a few minutes, it failed. That gap between "secure against ignorance" and "secure against knowledge" is the whole story of the Caesar cipher. It is the simplest possible example of a key space being too small to resist attack. Use the Caesar cipher encoder and decoder to follow along with the examples below.
Suetonius writes that Caesar replaced each letter with the letter three positions further in the alphabet. A became D, B became E, and so on through the alphabet. His nephew and successor Augustus Caesar used a shift of 1 instead, and reportedly did not wrap around at the end: Z became AA in his variant rather than cycling back to A. That distinction matters. It shows the cipher was understood as a variable-shift system from its earliest documented use, not as a single fixed rule.
The cipher reappears across centuries. A shift of 13, now called ROT13, turns up in Roman inscriptions and later in medieval manuscripts as a light obfuscation. Its modern life as a spoiler-hiding convention on internet forums dates to Usenet in the 1980s, where readers applied it to avoid revealing movie plots in plain text.
By the medieval period the Caesar cipher was too well known to provide any real security. Arab scholars had already moved past it. The philosopher and mathematician al-Kindi (c. 801 to 873 CE) wrote the Risalah fi Istikhraj al-Mu'amma ("A Manuscript on Deciphering Cryptographic Messages"), in which he described frequency analysis. That single technique defeats not only the Caesar cipher but every monoalphabetic substitution cipher, no matter how complex the substitution table. Al-Kindi's work is the oldest known systematic treatment of cryptanalysis, and it rendered the entire family of ciphers Caesar had used obsolete roughly nine centuries before European cryptographers caught up.
The Caesar cipher encrypts by shifting each letter forward by a fixed number of positions in the alphabet. The math is modular arithmetic.
Encryption: E(x) = (x + n) mod 26
Decryption: D(x) = (x - n) mod 26
Here x is the zero-based position of the plaintext letter (A=0, B=1, up to Z=25), n is the shift value (1 to 25), and mod 26 wraps the result around the alphabet so that Z+1 becomes A.
Worked example with a shift of 3:
``
Plaintext: S E C U R I T Y
Positions: 18 4 2 20 17 8 19 24
+3: 21 7 5 23 20 11 22 1
Ciphertext: V H F X U L W B
``
To decrypt, subtract 3 from each position and wrap with mod 26. V (21) minus 3 is 18, which is S. The operation reverses cleanly.
Numbers, spaces, and punctuation pass through unchanged. Only the 26 letters of the Latin alphabet are shifted. This preserves the visible word structure of the original message, which is itself an information leak: an attacker can see word lengths and sentence boundaries before they decrypt a single letter.
ROT13 as a special case. When the shift is 13, the cipher has a useful property. Because the English alphabet has 26 letters, applying ROT13 twice returns the original text:
``
(x + 13 + 13) mod 26 = (x + 26) mod 26 = x
``
The same operation encrypts and decrypts. There is no separate "decode" step. This is why ROT13 became the standard way to hide spoilers on forums: one pass hides the text, a second pass reveals it, and no key management is needed. You can test this with our ROT13 tool, which applies the same function in both directions.
Method 1: Brute force.
The Caesar cipher has a key space of exactly 25. Shifts of 1 through 25 each produce a distinct ciphertext. A shift of 0 is the identity (plaintext equals ciphertext) and a shift of 26 wraps back to the identity, so neither counts as a useful key.
Twenty-five possibilities is a trivial number. A human can write out all 25 shifts of a short ciphertext on paper in under five minutes. A computer does it in under one millisecond. Our Caesar brute force tool generates all 25 shifts at once so you can visually scan for the one that produces readable English.
This is why key space size is the first metric to check for any cipher. AES-128 has a key space of 2 to the power of 128, roughly 3.4 times 10 to the 38th. Brute-forcing that at a billion keys per second would take vastly longer than the current age of the universe. The Caesar cipher's 25 keys is the opposite extreme, and it is why the cipher is broken by exhaustion in practice.
Method 2: Frequency analysis.
Even if brute force were somehow impractical, frequency analysis breaks the Caesar cipher with a single statistical pass over the ciphertext. In English text, letter frequencies are stable. The letter E appears approximately 12.7% of the time, T approximately 9.1%, and A approximately 8.2%. These proportions hold across most English texts longer than a few hundred characters.
The Caesar cipher maps each plaintext letter to exactly one ciphertext letter. That one-to-one mapping means the frequency distribution is preserved in the ciphertext, just shifted. If the most common letter in your ciphertext is H, and E is the most common letter in English, then H probably maps to E, and the shift is 3. One measurement, one division, and the key is known. Our Letter Frequency Analyzer plots the distribution of any ciphertext, which makes the shifted pattern visually obvious.
Frequency analysis does have a limit. On texts shorter than roughly 100 characters, the sample is too small for the distribution to stabilize. A 20-letter ciphertext might have zero occurrences of E by chance. For short texts, brute force is the more reliable method. For anything longer, frequency analysis identifies the key from statistics alone.
The Caesar cipher has no role in modern security. It still has genuine uses in three contexts, none of which involve protecting secrets.
Capture the Flag challenges. CTF competitions on platforms like picoCTF and CryptoHack routinely include Caesar cipher problems as warmup exercises. The expected solution is brute force or frequency analysis, not manual letter counting. These problems exist to teach beginners the workflow of identifying a cipher, selecting a tool, and recovering the plaintext. A typical CTF Caesar challenge takes an experienced player under 30 seconds to solve.
Game design and easter eggs. Video game developers hide messages in in-game text using ROT13 or a small Caesar shift. A player finds a ciphertext scrawled on a sign or in a book, pastes it into a decoder, and reveals lore, coordinates, or a hidden quest. The shift is not meant to provide security. The point is the discovery: the player feels they cracked a secret, even though the "secret" is one of the weakest ciphers in history. Games like Fallout and Assassin's Creed have used this technique to reward curious players with bonus content.
Teaching cryptography. The Caesar cipher is the standard entry point in every introductory cryptography course because it illustrates three concepts at once: substitution, key spaces, and frequency analysis. A student can encrypt by hand, exhaust the 25 keys by hand, and count letter frequencies by hand. Once a student understands why 25 keys is far too few, the motivation for polyalphabetic ciphers like the Vigenere cipher becomes concrete rather than abstract. The Vigenere cipher was specifically invented to resist the frequency analysis that breaks the Caesar cipher, and seeing the break first makes the fix make sense.
The Caesar cipher has a key space of 25. It falls to brute force in under one millisecond and to frequency analysis on any text longer than roughly 100 characters. Its one-to-one letter mapping preserves word length and sentence structure, which leaks information to an attacker before decryption even begins.
Do not use this cipher to protect anything with actual value. For educational exercises, CTF challenges, and puzzle design, it is the right tool. For anything else, use a modern authenticated encryption scheme such as AES-GCM or ChaCha20-Poly1305, both of which have key spaces and security proofs that make the Caesar cipher look like what it is: a 2,000-year-old party trick.
According to Suetonius in The Twelve Caesars (c. 121 CE), Julius Caesar used a shift of 3, replacing A with D, B with E, and so on. His successor Augustus Caesar used a shift of 1 and reportedly did not wrap around the alphabet, writing Z as AA instead.
Yes. ROT13 is a Caesar cipher with a shift of 13. Because the English alphabet has 26 letters, ROT13 is self-inverse: applying it twice returns the original text, so the same operation encrypts and decrypts. It is commonly used on internet forums to hide spoilers.
25. Shifts of 1 through 25 each produce a distinct ciphertext. A shift of 0 returns the plaintext unchanged, and a shift of 26 is identical to a shift of 0 due to modular arithmetic, so neither is a useful key.
Yes, on any text longer than roughly 100 characters. The cipher maps each plaintext letter to exactly one ciphertext letter, so the frequency distribution is preserved but shifted. Finding the most common ciphertext letter and mapping it to E, the most common English letter at about 12.7%, reveals the shift directly.
No. Standard implementations rotate only the 26 letters of the Latin alphabet. Numbers, spaces, and punctuation pass through unchanged, which preserves visible word structure in the ciphertext and gives an attacker extra information before decryption.
Caesar Cipher
Encrypt or decrypt messages by shifting letters through the alphabet.
Caesar Brute Force
Try all 25 Caesar cipher shifts at once with automatic ranking by likelihood.
ROT13 Cipher
Simple letter substitution cipher that rotates letters by 13 positions.
Letter Frequency Analyzer
Count and analyze letter frequencies in text for cryptogram solving.
Vigenère Cipher
Polyalphabetic substitution cipher using a keyword for enhanced encryption.
Frequency Analysis Explained: How to Break Any Substitution Cipher
Al-Kindi discovered frequency analysis in 9th-century Baghdad. The technique still breaks CTF substitution ciphers today. Here is how it works and how to apply it.
How the Vigenere Cipher Works, and Why It Was Called Unbreakable
Understand how the Vigenere cipher uses a repeating key to defeat simple frequency analysis, and learn why the Kasiski examination breaks it anyway.
How to Solve a CTF Cryptography Challenge: A Practical Framework
The hardest part of CTF crypto is identifying what you are looking at. Learn the four-step recognition-to-decryption framework for classical, encoding, and substitution cipher challenges.