Caesar Cipher Tool
How it works
The Caesar cipher shifts each letter in a message by a fixed number of positions in the alphabet, wrapping around at Z. Named after Julius Caesar, who used a shift of 3 for military dispatches, it is the simplest substitution cipher — and the first cipher most people encounter in cryptography education.
**Encryption and decryption** Encryption: replace each letter A–Z with the letter n positions forward (shift n, modulo 26). Decryption: shift backward by n positions, equivalent to shifting forward by 26−n. Example with shift 13 (ROT13): A→N, B→O, ..., Z→M. With shift 3: A→D, B→E, ..., Z→C.
**Brute force** There are only 25 non-trivial shift values (shift 0 produces the original). Any message encrypted with a Caesar cipher can be cracked by trying all 25 shifts and choosing the readable one. A human can do this in under a minute; a computer in microseconds. The cipher offers no real security.
**Frequency analysis** Even without trying all shifts, frequency analysis breaks Caesar ciphers: count the most common letter in the ciphertext — it is almost certainly the encryption of E (the most common letter in English). If the most common ciphertext letter is H, the shift is H−E = 7 (H is 3 positions after E). This technique breaks any simple substitution cipher once you have ~50+ characters of ciphertext.
**ROT13 as a special case** ROT13 (shift=13) is self-inverse because 26÷2=13. This is the only shift value where applying the cipher twice returns the original without explicitly specifying "encrypt" vs "decrypt" — both directions are the same operation.
**Historical significance** The Caesar cipher introduced the concept of a key (the shift value) to cryptography. It inspired the Vigenère cipher (which uses multiple shifts) and, conceptually, modern stream ciphers (which XOR data with a keystream).
Privacy: all cipher operations run in the browser. No text is transmitted.
Frequently Asked Questions
- With any length of ciphertext, try all 25 non-trivial shifts (0 is the identity). For each shift, apply it and check if the result looks like English. Automated detection uses the Index of Coincidence (IC): English text has IC ≈ 0.065; random text has IC ≈ 0.038. The shift with the highest IC and/or the most common English words wins. A computer cracks any Caesar cipher in microseconds. Humans can often spot the right decryption in 1–3 guesses by looking for short common words (the, a, is, of).
- Letter frequency analysis is based on the known distribution of letters in English text: E appears about 12.7% of the time; T 9.1%; A 8.2%; O 7.5%; I 7.0%; N 6.7%, etc. In Caesar ciphertext, the most common letter is almost certainly the encryption of E. If the most common ciphertext letter is H, the shift is H(7) − E(4) = 3. If X, the shift is X(23) − E(4) = 19. This technique was first documented by Arab polymath Al-Kindi in the 9th century and breaks any simple monoalphabetic substitution cipher.
- The Vigenère cipher applies a different Caesar shift to each character position, using a repeating keyword as the key. For keyword 'KEY' (shifts 10, 4, 24): position 0 gets shift K=10, position 1 gets shift E=4, position 2 gets shift Y=24, position 3 gets shift K=10 again, etc. This was considered unbreakable for centuries ('le chiffre indéchiffrable') until Charles Babbage and Friedrich Kasiski independently developed methods to detect the key length (by finding repeated patterns in the ciphertext) and then applying Caesar cipher frequency analysis per position.
- Yes — Suetonius documented Caesar's use of a letter-shift cipher in 'The Life of Julius Caesar' (written ~120 CE, about events ~50 BCE): 'If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out.' Suetonius describes a shift of 3 (A→D). Caesar also reportedly used a shift of 1 for Greek and a shift of 13 for Latin in different communications. Whether the shift value of 3 was standard or varied is not confirmed.