🔐 Caesar Cipher

Shift every letter by a fixed amount to encode or decode text with the classic Caesar cipher. Letters wrap around the alphabet; numbers and punctuation are left unchanged.

How the shift is applied

Each letter is turned into its position in the alphabet, moved by the shift, and wrapped round with a modulo. Decoding is the same sum with the shift negated, and the doubled modulo keeps that from running off the front:

encode: out = (pos + shift) mod 26
decode: out = ((pos - shift) mod 26 + 26) mod 26

T is 19 -> (19 + 3) mod 26 = 22 -> W

With the default shift of 3, "The quick brown fox jumps over the lazy dog." encodes to "Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj." Switch to Decode with the same shift and you get the sentence back. Only A-Z and a-z move; digits, spaces and punctuation are copied through, and each letter keeps its case.

The shift box and the brute-force list

Accented and non-Latin letters fall outside A-Z, so they pass through unshifted and leave a visible fingerprint of the original text in the ciphertext.

Frequently asked questions

What is ROT13?

A Caesar cipher with a shift of 13. Because 13 is half of 26, encoding and decoding are the same operation, which is why forums have long used it to hide spoilers and punchlines. Set the shift to 13 and the mode stops mattering.

How do I decode a Caesar cipher without knowing the shift?

Paste the ciphertext, set the mode to Decode, and read the list of all 25 shifts underneath. One of them will be readable. There are only 25 possible keys, so no guesswork is needed.

Is the Caesar cipher secure?

No. With 25 keys it can be broken by hand in under a minute, and letter frequencies give it away even without trying them all. It is a puzzle and a piece of history, not protection for anything private.