How to use it
Type or paste a message into the upper box. Every letter moves the same number of places along the alphabet, wrapping from Z back to A, and the result appears below as you type. That number, the shift, is the key: turn the cipher wheel, press minus or plus, or type a number from 0 to 25. Switch to Decrypt to turn a secret message back with the same key.
Case is kept. Digits, spaces and punctuation pass through unchanged unless you choose “Letters only” or the classic “groups of 5”. Accented letters such as á, č or ž stay as they are by default; the other option removes the accents first, so they are shifted like plain letters. Letters with no plain form, such as ß or ł, never change.
The crack panel below plays the attacker: it sees only the ciphertext and scores all 26 shifts for how English they look.
Controls
- Cipher wheel: the outer ring is the plain alphabet, the inner ring the cipher alphabet. Drag the inner ring with a mouse or finger. With the wheel focused, the arrow keys turn it one step, Page Up and Page Down five, and Home sets 0.
- Key row: minus, plus, a shift box and ROT13. The strip lists all 26 letter pairs; the letter before the text cursor is highlighted there and on the wheel.
- Copy copies the result. Swap moves it into the input and flips the direction, so you can check the round trip.
- Crack panel: “Decrypt with shift …” or any row of the brute-force list applies that shift. The slider limits the attack to the first few letters.
- The shift and the options are remembered in this browser. Nothing you type is uploaded.
How it works
Number the letters A = 0, B = 1, …, Z = 25. With shift k:
With Caesar’s shift of 3, A becomes D and X wraps round to A. Only 26 shifts exist, so trying them all (the brute-force list) is easy even by hand.
The score is the chi-squared statistic. For a trial shift s, count each cipher letter i (Oi, out of N letters) and compare it with the count English would give, Ei = N · p(i − s), where p is the English frequency of the plain letter that would sit there:
The lowest score is the automatic guess. The English frequencies come from a standard published table (Robert Lewand, Cryptological Mathematics, 2000): E 12.7 %, T 9.1 %, A 8.2 % … Z 0.07 %. A shift slides this pattern along the alphabet without changing its shape, so at the right shift the English outlines sit on the bars. For the same reason the index of coincidence, the chance that two letters picked at random from the text match, is unchanged by encryption: about 0.066 for English, 0.038 for random letters.
Short texts break the method. With a dozen letters most counts are 0 or 1, and several shifts fit almost equally well. With about 10 letters the lowest score is often wrong; from about 30 letters of ordinary English it is almost always right. “Confident” means at least 20 letters and a runner-up score at least twice as high.
Things to try
- Drag “Letters used by the attack” down to a handful of letters. The verdict drops to Uncertain, and the shortest prefixes are often cracked wrongly.
- Try the pangram: 29 letters, yet the attack fails, because it uses rare Q, X and Z on purpose.
- Load a mystery message and turn the wheel slowly while watching the frequency chart.
- Press ROT13, then Swap: the same shift decrypts again, because 13 + 13 = 26.
- Encrypt with shift 5, paste the result back and encrypt it with shift 8. You get one shift of 13, so encrypting twice adds nothing.
Frequently asked questions
Did Julius Caesar really use it?
The source is the Roman historian Suetonius, writing in the early second century AD. He says that Caesar’s confidential letters put D in place of A, a shift of three, and that Augustus wrote B for A.
Is the Caesar cipher secure?
No. It has only 25 useful keys, and frequency analysis finds the right one from a few dozen letters. The earliest known description of frequency analysis is by the Arab scholar al-Kindi in the 9th century. Its unbreakable cousin, the Vernam cipher or one-time pad, gives every letter its own random shift from a key as long as the message, used only once.
What is ROT13?
Shift 13. Applying it twice gives back the original, so one button encodes and decodes. It became popular in online discussion groups in the early 1980s for hiding punchlines and spoilers, not secrets.
Why does the crack sometimes pick the wrong shift?
The score only measures how English the letter counts look. Very short messages, many rare letters, other languages or text that is not a Caesar cipher can all make a wrong shift win.
Sources
- Suetonius (early 2nd century AD). The Life of Julius Caesar, chapter 56. English translation in the Loeb Classical Library, 1913. Caesar’s letters with D written for A.
- Suetonius (early 2nd century AD). The Life of Augustus, chapter 88. Same translation. Augustus wrote B for A.
- Lewand RE (2000). Cryptological Mathematics. Mathematical Association of America. The English letter frequency table used by the crack.