The Caesar cipher
The Caesar cipher is one of the oldest known ways to hide a message. It is named after Julius Caesar, who, according to the historian Suetonius, shifted each letter of his private letters three places along the alphabet. A becomes D, B becomes E, and so on, wrapping around so that X becomes A. It is a simple substitution cipher and a favourite first step for anyone learning about cryptography.
How to use the tool
- Type your message and choose a shift from 1 to 25.
- Select Encrypt to shift letters forward or Decrypt to shift them back.
- If you have a coded message but not the key, click Try all 25 shifts and look for the line that reads as normal language.
How it works
Number the letters A = 0 to Z = 25. With a shift of k:
encrypt: C = (P + k) mod 26
decrypt: P = (C − k) mod 26
With shift 3, "HELLO" becomes "KHOOR". Capital and small letters keep their case, and spaces, digits and punctuation are left unchanged.
ROT13: the special case
A shift of 13 is called ROT13. Because the alphabet has 26 letters, shifting by 13 twice brings you back to the start, so the same operation both encrypts and decrypts. ROT13 has long been used on internet forums to hide puzzle answers and spoilers, not to keep anything secret.
Why the Caesar cipher is not secure
There are only 25 possible keys, so a computer, or a patient person, can try them all in seconds, which is exactly what the brute-force button does. Letter frequency also gives it away: E is the most common letter in English, so the most common letter in the coded text is probably E. Never use it to protect real information; for that, modern encryption such as AES is required.
Frequently asked questions
Does it work with Hindi or other scripts?
Only the 26 English letters are shifted. Other characters pass through unchanged.
Is there a stronger classical cipher?
Yes. The Vigenère cipher uses a keyword so each letter gets a different shift.
What is the difference with the Atbash cipher?
Atbash reverses the alphabet instead of shifting it, and has no key.