Caesar Cipher Converter
Shift every letter by a fixed number to encrypt or decrypt a message.
What it does
The Caesar cipher, also called a shift cipher, replaces every letter with one a fixed number of positions away in the alphabet. It is named after Julius Caesar, who reportedly used a shift of three for private messages.
This tool encrypts or decrypts a message with any shift from minus 25 to 25. Spaces, digits and punctuation pass through unchanged, and uppercase and lowercase letters keep their case.
The page opens with the message ATTACK AT DAWN and a shift of three. Encryption gives DWWDFN DW GDZQ, and decryption reverses the process.
Mathematically, letters are mapped to the numbers 0 through 25. Encryption adds the key and takes the result modulo 26. Decryption subtracts the key, again modulo 26.
The cipher offers no real security today because there are only 26 possible keys. Trying each one and looking for readable text breaks it almost instantly, which makes it useful mainly for teaching the idea of a key.
How to use
- Type the message to convert.
- Enter the shift as a whole number.
- Choose encrypt or decrypt.
- Read the converted message as the main result.
- Check the letter count to confirm how many characters moved.
- Decrypt the result with the same key to recover the original message.
Formula
- p
- Plaintext letter position from 0 to 25.
- k
- The shift key, a whole number from minus 25 to 25.
- c
- Ciphertext letter position from 0 to 25.
Only the value of the key modulo 26 matters, so a shift of 27 behaves like 1 and a shift of minus 1 behaves like 25. The tool keeps non letter characters unchanged and applies the modulo operation separately to uppercase and lowercase ranges.
Worked example
Example: ATTACK AT DAWN with shift 3
The page opens with the message ATTACK AT DAWN and a shift of 3 in encrypt mode.
- A moves three places to D.
- T moves three places to W, and the second T does the same.
- A becomes D, C becomes F and K becomes N.
- Spaces are left untouched, so ATTACK AT DAWN becomes DWWDFN DW GDZQ.
- Use decrypt mode with the same shift to recover ATTACK AT DAWN.
- The tool reports result DWWDFN DW GDZQ and letters shifted 12.
Reference table
| Input | Shift | Operation | Output |
|---|---|---|---|
| ATTACK AT DAWN | 3 | Encrypt | DWWDFN DW GDZQ |
| KHOOR ZRUOG | 3 | Decrypt | HELLO WORLD |
| HELLO WORLD | 1 | Encrypt | IFMMP XPSME |
Limits
- Messages are limited to 200 characters.
- Shifts must be whole numbers from minus 25 to 25.
- Only Latin letters are shifted; other characters pass through.
- This is a teaching cipher and offers no real security.
Common mistakes
- Adding the shift when decrypting instead of subtracting it.
- Forgetting that Z wraps back to A.
- Shifting spaces and punctuation along with letters.
- Assuming a shift of 26 changes the message.
- Treating the cipher as secure because the message looks scrambled.
Try it yourself
Quick checks. Answers sit tucked under each question.
Encrypt HELLO WORLD with shift 1.
IFMMP XPSME.
Decrypt KHOOR ZRUOG with shift 3.
HELLO WORLD.
What does a shift of 26 do?
Nothing. Only the shift modulo 26 matters, and 26 modulo 26 is zero.
Questions
What is a Caesar cipher?
A substitution cipher that shifts every letter by a fixed number of places.
Why is it called that?
It is named after Julius Caesar, who used a shift of three.
How do I decrypt?
Shift each letter backward by the same key, or use decrypt mode in this tool.
Is ROT13 related?
Yes. ROT13 is a Caesar cipher with a shift of 13.
Is it secure?
No. There are only 26 keys and a brute force search is trivial.
Does punctuation change?
No. Only letters are shifted, so spaces and symbols stay as they are.
Sources
- Brigham Young University, Caesar shift cipher lab
- Arizona State University, shift and Caesar cipher notes
- National Institute of Standards and Technology, the mathematics of cryptography