Caesar cipher
Shift every letter a fixed number of places down the alphabet.
- Family
- Monoalphabetic substitution
- Era
- 1st century BC
- Keys
- 25 useful keys
Suetonius records that Julius Caesar protected his military letters by replacing each letter with the one three places further down the alphabet. Any fixed shift works the same way, and the shift is the whole key.
Turn the inner ring of the wheel below to choose a shift, then step through your message to watch each letter move.
A = 0 … Z = 25
01 / 12 · Inside the Caesar cipher
A message to hide
This readable text is the plaintext. Encrypting turns it into ciphertext, which should mean nothing to anyone without the key. Classical ciphers only touch letters.
Everything that follows has one goal: whoever intercepts the ciphertext must not be able to get back to these letters.
Playground
Shift your own message
Type a message, pick a shift and step through it letter by letter. The panel on the right does the arithmetic on each of your letters.
Your input
Dwwdfn dw gdzq
Encrypt
Shift every letter by 3
What happens
Number the letters A = 0 … Z = 25. Encrypting adds 3 to each letter’s number, decrypting subtracts it. The two rings of the wheel show the result for all 26 letters at once.
On your values
E(x) = (x + 3) mod 26
A→D B→E Z→C
Why it matters
The key is one number between 1 and 25. That tiny keyspace (the set of all possible keys) is the cipher’s weakness: see how it’s broken below.
Spaces, digits and punctuation pass through unchanged; accents are dropped.
The basics: Modular arithmetic →Start
← → to step · space to playHow it’s broken
Try all 25 shifts, keep the one that reads
An attacker does not need the key: they shift the ciphertext back by every possible amount. Each candidate is scored by how typical its letters are in English (sum of the logarithm of each letter’s frequency); the highest score is almost always the message.
Attacking the ciphertext: Dwwdfn dw gdzq
- −1Cvvcem cv fcyp
- −2Buubdl bu ebxo
- −3Attack at dawn
- −4Zsszbj zs czvm
- −5Yrryai yr byul
- −6Xqqxzh xq axtk
- −7Wppwyg wp zwsj
- −8Voovxf vo yvri
- −9Unnuwe un xuqh
- −10Tmmtvd tm wtpg
- −11Sllsuc sl vsof
- −12Rkkrtb rk urne
- −13Qjjqsa qj tqmd
- −14Piiprz pi splc
- −15Ohhoqy oh rokb
- −16Nggnpx ng qnja
- −17Mffmow mf pmiz
- −18Leelnv le olhy
- −19Kddkmu kd nkgx
- −20Jccjlt jc mjfw
- −21Ibbiks ib liev
- −22Haahjr ha khdu
- −23Gzzgiq gz jgct
- −24Fyyfhp fy ifbs
- −25Exxego ex hear
−3 = best score
Shortcut: your ciphertext’s most common letter is D (3). If it stands for E (4), the shift is 3 − 4 + 26 = 25.
Short texts can fool the statistics: the longer the ciphertext, the surer the attack. Try the long-text preset.
How it works
- 1Pick a shift k between 1 and 25.
- 2For each letter, count k places forward in the alphabet, wrapping from Z back to A.
- 3Leave spaces, digits and punctuation as they are.
- 4To decrypt, count k places backward instead.
Formula
E(x) = (x + k) mod 26 D(x) = (x − k) mod 26
How it is broken
There are only 25 possible keys, so an attacker can try them all by hand in a few minutes.
Every letter is always replaced by the same letter, so the frequency pattern of the language survives: the most common ciphertext letter usually stands for E.