Back to Blog
Ancient Roman scroll with encrypted text
Security
caesar cipher
encryption
classical cipher
cryptography
shift cipher
ROT13

Caesar Cipher: The Classic Encryption Technique and How to Use It Online

The Caesar cipher is the oldest known encryption technique. Learn how it works, why it's still taught today, and how to encode and decode messages with a shift cipher online.

txt.tools Team 2025-02-12 8 min read

The History of the Caesar Cipher

Named after Julius Caesar, who used it in his private correspondence around 58 BC, the Caesar cipher is the oldest known encryption technique. Caesar would shift each letter in his military messages by three positions down the alphabet — A became D, B became E, C became F, and so on.

This simple substitution cipher was effective because most of Caesar's enemies were illiterate, and those who could read had no concept of code-breaking. Today, the Caesar cipher is trivially breakable, but it remains an important educational tool for understanding cryptography fundamentals.

How the Caesar Cipher Works

The Caesar cipher is a substitution cipher where each letter in the plaintext is shifted by a fixed number of positions in the alphabet.

Encryption Example (Shift 3)

Plaintext: HELLO

Shift: 3

Ciphertext: KHOOR

H (7) + 3 = K (10)

E (4) + 3 = H (7)

L (11) + 3 = O (14)

L (11) + 3 = O (14)

O (14) + 3 = R (17)

Decryption

Decryption reverses the shift. Knowing the shift value (key), you subtract it from the ciphertext to recover the plaintext.

The Full Shift Table (Shift 3)

| Plain | Cipher | Plain | Cipher | Plain | Cipher |

|-------|--------|-------|--------|-------|--------|

| A | D | J | M | S | V |
| B | E | K | N | T | W |
| C | F | L | O | U | X |
| D | G | M | P | V | Y |
| E | H | N | Q | W | Z |
| F | I | O | R | X | A |
| G | J | P | S | Y | B |
| H | K | Q | T | Z | C |
| I | L | R | U | | |

Notice that X, Y, Z wrap around to A, B, C. This wrapping is critical — the alphabet is treated as a circle.

Mathematical Description

In mathematical terms, the Caesar cipher is modular addition:

  • **Encryption:** E(x) = (x + n) mod 26
  • **Decryption:** D(x) = (x - n) mod 26
  • Where x is the letter's position (0-25) and n is the shift value (1-25).

    Breaking the Caesar Cipher

    The Caesar cipher has only 25 possible keys (shifts 1 through 25). This makes brute-force attacks trivial — simply try every shift and read the one that produces English text.

    Frequency Analysis

    A more sophisticated attack uses frequency analysis. In English, the most common letters are E, T, A, O, I, N, S, H, R. If "X" is the most common letter in the ciphertext, the shift is likely 19 (X - E = 23 - 4 = 19).

    Automated Cracking

    Modern Caesar cipher tools can crack any message instantly by trying all 25 shifts and scoring each result against English letter frequency patterns.

    | Letter | Frequency |

    |--------|-----------|

    | E | 12.7% |
    | T | 9.1% |
    | A | 8.2% |
    | O | 7.5% |
    | I | 7.0% |
    | N | 6.7% |
    | S | 6.3% |
    | H | 6.1% |
    | R | 6.0% |

    ROT13: The Special Case

    ROT13 is a Caesar cipher with a shift of 13. It's special because the alphabet has 26 letters, so applying ROT13 twice returns the original text. ROT13 is commonly used on the internet for obfuscating spoilers, puzzle answers, and offensive content without true encryption.

    When to Use (and Not Use) the Caesar Cipher

    Use for:

  • Educational purposes — learning how substitution ciphers work
  • Puzzles and games — hiding answers or clues
  • Low-stakes obfuscation — hiding text from casual viewers
  • Historical demonstrations
  • Never use for:

  • Actual security — it takes seconds to break
  • Sensitive data — never encrypt personal information with Caesar
  • Professional applications — use AES or other modern standards
  • Variations of the Caesar Cipher

    **ROT5:** Shifts digits 0-9 by 5 positions. Often combined with ROT13 for full alphanumeric obfuscation.

    **ROT47:** Shifts all printable ASCII characters (codes 33-126) by 47 positions. More thorough than ROT13 but equally insecure.

    **Shifted alphabet:** Instead of shifting, some variants reverse or scramble the alphabet. These are still substitution ciphers and equally vulnerable.

    Conclusion

    The Caesar cipher is a fascinating piece of cryptographic history. While completely insecure by modern standards, it remains an excellent teaching tool for understanding encryption concepts, frequency analysis, and the evolution of secret communication.

    Encode and decode messages with our free Caesar Cipher tool at txt.tools. Choose any shift value from 1 to 25, see instant results, and watch your messages transform.

    Advertisement

    Enjoyed this article?

    Check out our free online tools at txt.tools to help you work faster and smarter.