Skip to content
BCBinary Code Translator
Menu

Classical substitution cipher

Caesar Cipher Encoder / Decoder

Shift English A-Z letters forward or backward by a configurable amount, preserve case and every non-letter, and switch instantly to ROT13 while keeping the security limitation explicit.

The letter substitution runs locally in the browser, but local processing does not make the Caesar cipher secure.

Conversion direction

Conversion runs locally in this browser. The input is not uploaded.

What the Caesar cipher is

The Caesar cipher is a monoalphabetic substitution in which each letter is replaced by another letter a fixed number of positions away. With shift three, A becomes D, B becomes E, and X, Y, Z wrap around to A, B, C. Decoding moves in the opposite direction by the same shift. The method is named after Julius Caesar’s reported use of letter shifting for military correspondence.

This implementation defines the alphabet precisely as the twenty-six ASCII English letters A-Z and a-z. Case is preserved, and characters outside those ranges—including digits, spaces, punctuation, accented letters, CJK characters, and emoji—are copied unchanged. A shift may be any whole integer; it is normalized modulo twenty-six, so 29 behaves like 3 and -1 behaves like 25 for encoding.

The Caesar cipher is not secure encryption. There are only twenty-six possible shifts, including the identity shift, and language patterns remain visible. A person or trivial program can try every shift immediately. Use this page for education, puzzles, historical examples, and compatibility testing, never for passwords, private messages, tokens, personal data, or any situation requiring confidentiality.

How to encode or decode a Caesar shift

  1. Choose Encode to move letters forward or Decode to move them backward.
  2. Enter a whole-number shift. Values outside 0-25 are normalized modulo 26, which makes negative and large values predictable.
  3. Type or paste the text. The result updates while preserving letter case and every non-ASCII or non-letter character.
  4. Use the ROT13 shortcut to set shift 13. ROT13 uses the same operation for encoding and decoding because it is self-inverse.
  5. If the shift is unknown, test all twenty-six possibilities and judge the readable result; this tool does not pretend that brute-force recovery is cryptanalysis-grade security.

Caesar shift and ROT13 examples

The examples cover wraparound, case preservation, negative-equivalent shifts, non-English text, decode direction, and ROT13’s self-inverse behavior.

Classic shift 3

Input: Attack at Dawn!

Output: Dwwdfn dw Gdzq!

Uppercase and lowercase letters shift independently, while spaces and punctuation remain unchanged.

Decode shift 3

Input: Dwwdfn dw Gdzq!

Output: Attack at Dawn!

Decode subtracts the normalized shift instead of requiring a separate negative number.

Alphabet wraparound

Input: xyz XYZ

Output: abc ABC

Letters past z or Z wrap to the beginning of the same alphabet.

ROT13

Input: Hello, World!

Output: Uryyb, Jbeyq!

A shift of thirteen is its own inverse because applying it twice advances by twenty-six positions.

Large shift normalization

Input: abc

Output: def

A shift of 29 is normalized modulo 26 and behaves exactly like shift 3.

Preserved nonletters

Input: Hello, 世界! 123

Output: Khoor, 世界! 123

This implementation shifts only ASCII A-Z and a-z; all other characters pass through unchanged.

Shift range and character behavior

The shift control accepts finite integers. Internally the value is reduced with a positive modulo operation, producing a number from zero through twenty-five. Decode applies the complementary movement, so decode shift three is equivalent to encode shift twenty-three.

Only code points for ASCII A-Z and a-z are transformed. This narrow rule avoids claiming a universal alphabet for every language. Extending Caesar-style rotation to accented or non-Latin scripts requires an explicitly ordered alphabet and language-specific decisions.

  • Shift 0 and every multiple of 26 return the original text.
  • Shift 13 is ROT13 and applying it twice restores the input.
  • Uppercase letters remain uppercase and lowercase letters remain lowercase.
  • Spaces, punctuation, digits, emoji, and non-Latin scripts are preserved exactly.
  • Fractional, infinite, or non-numeric shifts are invalid.

How modulo-26 letter rotation works

Each ASCII letter is converted to a zero-based alphabet index. For uppercase A is zero and Z is twenty-five; lowercase uses the same indexes with a different character-code offset. Encoding adds the normalized shift, takes the result modulo twenty-six, and converts the index back to a character.

Decoding can subtract the shift directly or add its complement, 26 minus the normalized shift. Using the complement keeps every intermediate value non-negative. Wraparound is therefore a property of modular arithmetic rather than a list of special cases for X, Y, and Z.

The function processes Unicode code points but transforms only one-unit ASCII letters. Other characters are returned unchanged. There is no key schedule, randomness, initialization vector, block mode, authentication tag, or secret state. The entire keyspace is the visible shift value.

Appropriate uses for a Caesar cipher

The cipher remains useful because it demonstrates substitution and modular arithmetic with almost no machinery. Its weakness is part of the lesson.

Classroom exercises

Show letter indexes, modular wraparound, frequency analysis, and the difference between encoding, encryption, and secure cryptography.

Puzzles and escape games

Create hints that are intentionally recoverable by trying a small number of shifts.

ROT13 community conventions

Obscure spoilers or punchlines in contexts where everyone understands that the text is not protected.

Programming practice

Test string iteration, character classes, case preservation, negative modulo behavior, and reversible transformations.

Historical demonstrations

Illustrate why a once-practical manual method is inadequate against modern computation and statistical analysis.

Caesar cipher limitations and mistakes

The most serious mistake is treating the result as confidential. Trying every possible shift takes negligible time, and ordinary-language scoring can identify the likely plaintext automatically. Even without brute force, repeated letters, word lengths, and punctuation remain visible.

Operational mistakes are usually direction or shift mismatches. Because shift 23 encoding matches shift 3 decoding, users can become confused when two different-looking settings produce the same transformation. Normalizing and displaying the intended direction keeps the model clear.

  • A wrong shift produces another reversible substitution, not an integrity error.
  • The cipher cannot detect whether decoded text is correct.
  • Non-English letters are preserved rather than rotated through an invented alphabet.
  • ROT13 is obfuscation and can be reversed by the same operation.
  • Do not use Caesar output for secrets, authentication, storage protection, or secure transport.

Caesar compared with ROT13 and modern encryption

ROT13 is exactly the Caesar cipher with shift thirteen. Because thirteen plus thirteen equals twenty-six, encoding and decoding are identical. Atbash is another classical substitution, but it reverses the alphabet rather than applying a constant rotation.

Modern authenticated encryption such as AES-GCM or ChaCha20-Poly1305 operates on bytes with large secret keys, nonces, and integrity tags. It is designed to resist attackers who know the algorithm. Caesar relies entirely on hiding one of twenty-six shifts and offers no authentication.

ROT13

A fixed shift of 13 used for casual obfuscation. It has the same security level as every other Caesar shift.

Atbash

Maps A to Z, B to Y, and so on. It is also a fixed monoalphabetic substitution and is not secure.

Authenticated encryption

Uses a real secret key and integrity verification. Choose a maintained cryptographic library instead of implementing it in a text utility.

Caesar cipher FAQ

Is the Caesar cipher secure encryption?

No. The entire keyspace has only twenty-six shifts, and language patterns remain visible. It is suitable for learning and puzzles, not for protecting any sensitive information.

What happens when the shift is greater than 25?

The tool normalizes every integer modulo 26. Shift 29 becomes 3, shift 26 becomes 0, and shift -1 becomes 25 for encoding.

Does the tool preserve punctuation and numbers?

Yes. It shifts only ASCII A-Z and a-z. Spaces, punctuation, digits, accented letters, non-Latin scripts, and emoji remain unchanged.

Is ROT13 different from a Caesar cipher?

ROT13 is the Caesar cipher with a fixed shift of thirteen. It is self-inverse, so applying ROT13 twice restores the original text.

How can I decode text when I do not know the shift?

Try all twenty-six shifts and inspect the results. For natural language, readable words usually reveal the correct candidate immediately, which demonstrates the cipher's weakness.

Why not rotate accented or non-Latin letters too?

Those scripts need a defined ordered alphabet and language-specific rules. This tool states a precise ASCII scope instead of applying an arbitrary or misleading rotation.

Related text and encoding tools

View all tools

Cookie Preferences

Manage your cookie preferences. Necessary cookies cannot be disabled.

Necessary

Required

Required for language selection, privacy choices, and basic site functionality.

Cookies: NEXT_LOCALE

Analytics

Optional analytics cookies help us understand traffic and improve the website.

Cookies: _ga, _gid, _gat, _clck, _clsk

Advertising

Optional advertising cookies may be used to show relevant ads and measure performance.

Cookies: __gads, _gcl_au, IDE