Caesar Cipher
Encode and decode the Caesar cipher with any shift. Includes brute-force view of all 26 shifts.
Encode and decode the Caesar cipher with any shift from 1 to 25. Includes ROT-N, brute-force preview, and case preservation. Read more Show less
What is the Caesar cipher?
The Caesar cipher is a substitution cipher in which each letter is shifted a fixed number of positions down the alphabet. It is named after Julius Caesar, who reportedly used a shift of 3 to protect military correspondence. It is one of the oldest and simplest ciphers in existence, and it is the standard first lesson in cryptography because it demonstrates the core idea - a keyed transformation - without any implementation complexity.
There are only 26 possible shifts, and a shift of 0 leaves the text unchanged. Because the alphabet wraps, a shift of 26 is identical to 0, a shift of 27 to 1, and so on. In practice only 25 distinct ciphers exist, plus the trivial identity.
How to use
Choose a shift (1-25) and a direction, then type or paste into the input. The output updates live.
Encode shifts forward: A + 3 becomes D. Decode shifts backward: D - 3 becomes A. Both directions preserve case - lowercase stays lowercase, uppercase stays uppercase - and leave digits, punctuation, and whitespace unchanged.
Because shifts wrap around the 26-letter alphabet, a shift of 23 forward is identical to a shift of 3 backward. This tool does not enforce any convention: choose any shift from 1 to 25 in either direction.
Brute-force view
With only 26 possible keys, a Caesar cipher can always be broken by hand in under a minute. Enable the brute-force view to see all 26 shifts of the input at once. Scan the results for the one that reads as real text - that is the plaintext, and the shift that produced it is the key.
Most of the 26 rows will look like nonsense. One will look like the original message. Occasionally two will look plausible (for very short inputs), and then you need to rely on context to decide.
History and variants
The Caesar cipher is named for Julius Caesar (100-44 BC), who according to Suetonius used a shift of 3 for confidential correspondence. His nephew Augustus used a shift of 1, but with the peculiarity that he did not wrap the alphabet at the end - instead, he substituted AA for X, BB for Y, and CC for Z. That variant is sometimes called the Augustus cipher.
ROT13, still in common use online for casual obfuscation, is the Caesar cipher with a fixed shift of 13. It is self-inverse: the same operation both encrypts and decrypts, which is why tools that implement ROT13 do not need a separate direction.
Caesar is a special case of the more general affine cipher, in which letters are transformed as (a·x + b) mod 26. When a = 1, the affine cipher reduces to Caesar with shift b.
Why the Caesar cipher is not secure
The Caesar cipher offers no confidentiality whatsoever. It has 25 possible keys, all of which can be tried in the time it takes to read this sentence. Frequency analysis - the fact that E is the most common letter in English, followed by T, A, O, I, N - trivially reveals the shift even without trying all 25.
Do not use Caesar or ROT-N for anything that matters. It is a teaching tool and a puzzle-solving tool. For actual encryption, use AES-GCM or ChaCha20-Poly1305, both available as tools on this site.
FAQ
Is Caesar cipher the same as ROT13?
ROT13 is a special case of Caesar with a fixed shift of 13. Because 13 is exactly half of 26, ROT13 is self-inverse. The general Caesar cipher with an arbitrary shift is not.
What shift did Julius Caesar use?
Suetonius records a shift of 3. That convention - ROT3 - is sometimes called the Caesar shift, but the term "Caesar cipher" is now used for any fixed shift.
Can I use any shift value?
Any integer works, but only shifts 1-25 produce a cipher distinct from the identity. A shift of 0 is no encryption at all. A shift of 26 or a multiple of 26 is equivalent to 0. Negative shifts are equivalent to their positive counterparts mod 26 - a shift of -3 is the same as 23.
Does the Caesar cipher work on non-English alphabets?
Classical Caesar is defined for the 26-letter Latin alphabet. This tool passes any non-ASCII character through unchanged. You could in principle define Caesar shifts on other alphabets (Cyrillic, Greek, Hebrew), but that is a different tool.
What is the difference between Caesar and Vigenere?
Caesar uses a single fixed shift for the entire message. Vigenere uses a repeating keyword as the shift sequence, so each letter is shifted by a different amount. Vigenere is much stronger against frequency analysis - for centuries it was called "le chiffre indechiffrable" - until Kasiski's method broke it in 1863.
Command line equivalent
# Python
python3 -c 'print("".join(chr((ord(c)-65+3)%26+65) if c.isupper() else chr((ord(c)-97+3)%26+97) if c.islower() else c for c in "Hello, World!"))'
# OpenSSL (not applicable - Caesar is not a supported algorithm)
# ROT13 via Python codecs (special case, shift = 13)
python3 -c 'import codecs; print(codecs.encode("Hello, World!", "rot13"))'
# Brute force (bash)
for n in {1..25}; do echo -n "$n: "; echo "Khoor Zruog" | tr 'A-Za-z' "$(printf '%s' {A..Z} | cut -c$((n+1))-26,1-$n)$(printf '%s' {a..z} | cut -c$((n+1))-26,1-$n)"; echo; done