Caesar Cipher

The Caesar Cipher, attributed to Julius Caesar, is a simple substitution cipher that shifts each letter in the alphabet by a fixed number. It’s an early example of encryption, easy to understand but insecure today. This article covers its mechanics, an example, weaknesses, and history.

How It Works

Each letter is shifted by \( k \) positions:

  • Encryption: \( C = (P + k) \mod 26 \), where \( P \) is the plaintext position (A=0, B=1, …).
  • Decryption: \( P = (C - k) \mod 26 \).

Numbers represent letters in a 26-letter alphabet.

Example Encryption

Encrypt “HELLO” with \( k = 3 \):

  • H (7) → 7 + 3 = 10 → K
  • E (4) → 4 + 3 = 7 → H
  • L (11) → 11 + 3 = 14 → O
  • L (11) → 11 + 3 = 14 → O
  • O (14) → 14 + 3 = 17 → R

Result: “KHOOR”. Decrypt: Shift back by 3.

Weaknesses

  • Limited Keys: Only 25 possible shifts.
  • Frequency Analysis: Letter patterns (e.g., “E” is common) reveal the shift.
  • Brute Force: Easily cracked by trying all shifts.

It’s obsolete for modern security.

Historical Use

Used by:

  • Julius Caesar: For military messages (~50 BCE).
  • Education: Teaching basic cryptography concepts.
  • Puzzles: Simple codes in games or books.

It’s a stepping stone to advanced ciphers.