Caesar Cipher Encoder/Decoder
Encode and decode text using the classic Caesar cipher (shift cipher). Includes ROT13 and brute-force decoder.
100% client-side processing
Encode and decode text using the classic Caesar cipher (shift cipher). Includes ROT13 and brute-force decoder.
100% client-side processing
The Caesar cipher is the oldest substitution cipher most people ever learn, and it remains the clearest way to see why secret methods are not the same as security. This tool encodes and decodes text at any shift from 1 to 25, offers a one-click ROT13 toggle, and can brute-force an unknown shift by showing all 25 possible decodings side by side.
The rule is a single modular addition. Number the letters A=0 through Z=25, then for a shift k:
encoded = (letter + k) mod 26
decoded = (letter - k) mod 26
Modulo 26 is what makes the alphabet wrap: X shifted by 4 goes to B, not past the end of the alphabet. The tool computes the decode direction as (26 - k) mod 26 and adds that instead, which is algebraically identical to subtracting k.
Case is preserved because uppercase and lowercase letters are handled against separate bases: uppercase counts from 65 ('A'), lowercase from 97 ('a'). Anything outside those ranges is appended untouched.
A shift of 3, the shift Julius Caesar is said to have used:
| Step | Result |
|---|---|
| Plaintext | ATTACK AT DAWN |
| Shift each letter +3 | DWWDFN DW GDZQ |
| Decode with shift 3 | ATTACK AT DAWN |
ROT13 applied to the same text gives NGGNPX NG QNJA. Run ROT13 again and you get ATTACK AT DAWN back, because 13 + 13 = 26 and 26 mod 26 = 0. Try shift 13 in the brute-force panel and you will see those two lines appear as the only readable pair.
Digits, punctuation, and spaces are never transformed, which is why the word boundaries in the example above stay exactly where they were.
With 25 possible keys, an unknown shift is not a puzzle — it is a lookup. The tool calls its shift function once for every value from 1 to 25 and lists the results. The only challenge left is recognizing the plaintext, and language makes that easy: the correct line is the one containing real words. If a message had no spaces and mixed languages, frequency analysis would do the same job by looking for the telltale distribution of English letters, where E, T, A, O, I, and N dominate.
A Caesar cipher is a substitution with a key space of 25 and a fixed mapping. Modern encryption needs two properties it lacks: a key large enough that exhaustive search is infeasible, and a construction that resists analysis even when the algorithm is public. AES, by contrast, uses 128- or 256-bit keys, and its security does not depend on attackers being ignorant of how it works. Never use a Caesar shift — or ROT13 — to protect passwords, personal data, or anything that matters. For real confidentiality, encrypt with AES and treat the output as binary.
The Caesar shift is the simplest member of a family of classical ciphers, and seeing the family together explains why each was replaced.
| Cipher | Key | Key space | Weakness |
|---|---|---|---|
| Caesar | A single shift | 25 | Exhaustive search and frequency analysis |
| Atbash | None (fixed reversal) | 1 | No key at all; anyone who knows the method reads it |
| ROT13 | Fixed shift of 13 | 1 | A Caesar case, self-inverse and trivially reversible |
| Vigenère | A repeating keyword | Very large | Broken by Kasiski examination and index of coincidence |
| AES-256 | 256-bit binary key | 2^256 | No practical attack known when used correctly |
Atbash maps A to Z, B to Y, and so on; it is a Caesar shift wearing a disguise and offers even less. Vigenère is the interesting step up because a repeating keyword defeats straightforward frequency analysis, which is why it held for centuries — but the repetition itself leaks the key length, and once that is known the message falls apart. A modern block cipher like AES removes the repetition entirely and makes the output indistinguishable from random data.
There are only 25 useful keys, so anyone can try every shift in seconds, and frequency analysis breaks it even faster: in English text the most common letter is almost always E, so whichever shift maps the most frequent ciphertext letter to E is almost certainly correct. It provides no protection against anyone who knows the method.
Encoding adds the shift to each letter; decoding subtracts it. Internally the decode direction uses an effective shift of (26 - shift), so encoding with shift 3 and then decoding with shift 3 returns the original text.
It does not touch them. Only the 26 uppercase and 26 lowercase Latin letters are shifted; everything else — accents like é, digits, punctuation, spaces, Cyrillic, CJK, and emoji — passes through unchanged. A word like café becomes pdsé at shift 3, with the é left alone.
A shift of 0 or 26 would leave the text identical, and all other integers reduce to the range 1-25 modulo 26. The interface enforces that range so every position on the slider produces a visible change.
ROT13 is a Caesar shift of 13, and 13 is exactly half of 26, which makes it self-inverse: applying ROT13 twice restores the original. That property makes it a convenient reversible obfuscation for spoilers and puzzle answers, where the goal is to avoid reading by accident, not to keep secrets.
It moves the current output into the input field and flips the mode from encode to decode or vice versa. That is handy after a brute-force decode: once you spot the readable line, Swap lets you verify it by re-encoding.
Reviewed by the HandyTools Hub team · Last updated