Caesar Cipher Calculator
A Caesar cipher shifts each letter a fixed number of places along the alphabet, wrapping past Z back to A. It is the simplest substitution cipher and a classic introduction to cryptography. Enter your text and a shift to encode it, or set decode to recover the original. A shift of 13 gives ROT13, which is its own inverse. Non-letter characters pass through unchanged and letter case is preserved.
Caesar cipher formula
map A..Z to 0..25 (case preserved)
encode: new index = (index + shift) mod 26
decode: new index = (index - shift + 26) mod 26
non-letters unchanged
Each letter is converted to a number, shifted modulo 26 so the alphabet wraps, then converted back. The shift is the key. Decoding reverses the shift. A shift of 13 (ROT13) encodes and decodes identically.
Worked example
Encode "Hello, World!" with shift 3. H to K, e to h, l to o, l to o, o to r, then the comma and space unchanged, W to Z, o to r, r to u, l to o, d to g, exclamation unchanged. The result is "Khoor, Zruog!". Decoding "Khoor, Zruog!" with shift 3 returns "Hello, World!".
Caesar cipher: frequently asked questions
What is a Caesar cipher?
A Caesar cipher shifts each letter of the alphabet a fixed number of places. With a shift of 3, A becomes D, B becomes E and so on, wrapping around so X, Y, Z become A, B, C. It is one of the oldest known substitution ciphers and is named after Julius Caesar.
How does the shift work mathematically?
Map each letter to a number 0 to 25 (A = 0). To encode, new index = (index + shift) mod 26; to decode, new index = (index - shift + 26) mod 26. Non-letter characters are left unchanged. ROT13 is simply a Caesar cipher with a shift of 13, which is its own inverse.
Is a Caesar cipher secure?
No. With only 25 possible shifts it can be broken instantly by trying every shift, and letter-frequency analysis reveals the key just as fast. It is a teaching tool and a puzzle, not real encryption.
What is ROT13?
ROT13 is a Caesar cipher with a shift of 13. Because 13 is half of 26, applying ROT13 twice returns the original text, so the same operation both encodes and decodes. It is commonly used to hide spoilers, not to protect data.
Sources and references
- NIST Computer Security Resource Center: cipher and substitution glossary.
- NIST Computer Security Resource Center: cryptographic standards and guidelines.
- Algorithm: standard modular-shift substitution (Caesar cipher / ROT13).
Reviewed by the CalculatorHub team, edited by James Graham, 19 June 2026. See our methodology.