Calculateus

Caesar Cipher Encoder/Decoder

Encode or decode text using a Caesar cipher (letter-shift substitution).

Result

Result
Khoor Zruog

About the Caesar Cipher

The Caesar Cipher Encoder/Decoder shifts every letter in a block of text forward or backward through the alphabet by a chosen number of positions, recreating one of the oldest substitution ciphers in cryptography. Enter text, pick a shift amount, and choose encode or decode to see the transformed result instantly. Setting the shift to 13 reproduces the well-known ROT13 cipher used to casually obscure spoilers and forum content.

How It Works

The tool takes three inputs: the text, a whole-number shift amount, and a mode (encode or decode). In encode mode, each letter's position in the alphabet is shifted forward by the shift amount, wrapping back to A after Z (or a after z); decode mode applies the same shift in reverse. Characters that aren't letters, such as numbers, spaces, and punctuation, pass through completely unchanged.

For each letter with character code c and alphabet base b (65 for uppercase A-Z, 97 for lowercase a-z): shifted position = ((c - b + shift) mod 26 + 26) mod 26, and the new letter equals base + shifted position. In decode mode, the shift value is negated before this formula is applied.

Formula & Methodology

Working an example by hand: encoding H (code 72, base 65) with shift 3 gives (72 - 65 + 3) mod 26 = 10, so the new letter is base 65 + 10 = 75, which is K. Applying that same process letter by letter turns 'Hello World' into 'Khoor Zruog'. Because the formula adds 26 before taking the final modulo, negative results from decode mode, or from shifts larger than 26, still wrap correctly to a valid letter instead of breaking the calculation.

Examples

Encoding with Shift 3

Encoding 'Hello World' with a shift of 3 produces 'Khoor Zruog', with each letter moved three positions later in the alphabet and the space left untouched.

ROT13 Is Its Own Reverse

Encoding 'Attack at dawn' with shift 13 produces 'Nggnpx ng qnja'; running that same shift-13 encoding on the result a second time returns the original phrase, since 13 + 13 = 26 wraps all the way back around the alphabet.

Advantages

  • Handles both encoding and decoding with the same formula, so there's no need to work out the reverse shift by hand.
  • Supports any whole-number shift, not just the ROT13 special case, useful for classroom demonstrations of how weak single-shift substitution really is.
  • Preserves capitalization, spacing, and punctuation exactly, so the output reads naturally instead of collapsing everything to one case.

Common Mistakes

  • Treating the Caesar cipher as secure for protecting real information, when only 25 possible shifts exist, making it breakable in seconds by brute force or basic letter-frequency analysis.
  • Re-encoding already-encoded text with the same positive shift instead of switching to decode mode, which shifts the text twice as far rather than reversing it.
  • Expecting numbers or symbols in the input to shift along with the letters, when the formula only touches alphabetic characters.

Edge Cases to Watch For

  • Only ASCII letters a-z and A-Z are transformed; digits, punctuation, spaces, and non-English characters are left exactly as typed.
  • The shift amount is rounded to the nearest whole number before use, so a fractional shift like 3.7 is treated as 4.
  • Because of the double modulo wrap, shifts outside the 0-25 range behave identically to their equivalent within that range, meaning a shift of 29 produces the exact same output as a shift of 3.

Common Use Cases

  • Students and teachers demonstrating basic substitution ciphers in an introductory cryptography or computer science lesson.
  • Puzzle, escape-room, or alternate-reality-game designers who want a quick, reversible way to obscure a clue.
  • Forum or discussion-board authors using ROT13 to hide spoilers or answers from casual readers.
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

Is a Caesar cipher secure for protecting real information?

No - a Caesar cipher only has 25 possible shift values, so it can be broken almost instantly by trying every shift or through basic frequency analysis. It's a classic teaching example of cryptography and useful for lightweight puzzles or obfuscation, not for protecting anything actually sensitive.

Conclusion

The Caesar cipher is a teaching tool more than a security tool, and this calculator makes that easy to explore by letting you try any shift value on any text instantly. Its value is historical and educational, not cryptographic.