What the Caesar cipher is
The Caesar cipher replaces each letter with the letter a fixed number of places further along the alphabet. With a shift of 3, A becomes D, B becomes E, and so on. At the end the alphabet wraps around, so X becomes A, Y becomes B and Z becomes C.
It is named after Julius Caesar, who, according to the Roman historian Suetonius, used a shift of three in private letters. It is one of the oldest known ciphers and still the first one most people learn.
The shift is the key. Anyone who knows it can reverse the message by shifting the same number of places back.
How to use the tool
To encrypt. Type your message in Plain text. The coded version appears in Cipher text as you type.
To decrypt. Paste the coded message into Cipher text. The readable version appears in Plain text.
To change the key. Drag the Shift slider, or press the minus and plus buttons to step one place at a time. Whichever box you typed in last stays fixed and the other box updates.
To crack a message with an unknown key. Paste it into Cipher text and look at the list headed All 25 shifts of the cipher text. Every possible answer is shown. The one that looks most like English carries a Most likely English tag. Press the number button next to any line to set the slider to that shift.
Press Copy above either box to copy its text, or Clear to start again.
Examples
These results come from running the cipher on this page.
| Plain text | Shift | Cipher text |
|---|---|---|
| Hello, World! | 3 | Khoor, Zruog! |
| Hello, World! | 7 | Olssv, Dvysk! |
| Meet me at the old oak tree | 3 | Phhw ph dw wkh rog rdn wuhh |
| ATTACK AT DAWN | 13 | NGGNPX NG QNJA |
| Zebra crossing | 1 | Afcsb dspttjoh |
| The quick brown fox | 23 | Qeb nrfzh yoltk clu |
A shift of 23 is the same as a shift of 3 backwards. That is why “The” becomes “Qeb”.
Here is the start of the brute-force list for Phhw ph dw wkh rog rdn wuhh:
| Shift tried | Result |
|---|---|
| 1 | Oggv og cv vjg qnf qcm vtgg |
| 2 | Nffu nf bu uif pme pbl usff |
| 3 | Meet me at the old oak tree |
| 4 | Ldds ld zs sgd nkc nzj sqdd |
The tool tags shift 3 as most likely English.
How it works
Each letter is turned into a number from 0 to 25. The shift is added, and the total wraps round past 25 back to 0. Written as a formula, with x as the letter’s position and n as the shift:
- Encrypt: (x + n) mod 26
- Decrypt: (x - n) mod 26
To pick the most likely shift, the tool counts how often each letter appears in each of the 25 candidate texts and compares those counts with typical English letter frequencies. E, T and A are common in English. Q, X and Z are rare. The candidate whose letters fit that pattern best gets the tag. This works well on a sentence or more. On a very short message, such as a single word, check the list yourself, because several shifts can produce real words.
Limits and security
The Caesar cipher is not real encryption. With only 25 keys, anyone can try them all. Even without a computer, letter frequency gives the key away quickly in a longer message.
Use it for:
- Puzzle hunts, escape rooms and geocaching clues.
- Teaching how ciphers and keys work.
- Hiding spoilers or answers from a casual glance.
Do not use it for passwords, private messages or anything that needs protecting. For that, use modern encryption built into trusted apps.
Other ways to do it
On Linux, macOS or Git Bash, the tr command can apply a fixed shift. This line shifts by 3:
echo 'Hello, World!' | tr 'A-Za-z' 'D-ZA-Cd-za-c'
It prints Khoor, Zruog!. To decrypt, swap the two letter ranges, or shift forward by 23 with tr 'A-Za-z' 'X-ZA-Wx-za-w'.
In Python, a one-line version for capital letters is:
''.join(chr((ord(c)-65+3)%26+65) if c.isupper() else c for c in 'HELLO')
That returns KHOOR. In Excel, the same idea uses CODE, MOD and CHAR on each letter, which gets long for whole sentences.
Related ciphers
A shift of 13 has its own page: the ROT13 encoder and decoder. To swap letters for their position in the alphabet, use the A1Z26 cipher. For a code made of signals rather than letters, try the Morse code translator.