Advertisement

Caesar Cipher

Each letter is shifted by a fixed number of positions in the alphabet.

Learn

Each letter is shifted by a fixed number of positions in the alphabet.

The Caesar cipher shifts each letter by a fixed number of positions. If the shift is 3, A becomes D, B becomes E, and so on. At the end of the alphabet, it wraps around: X→A, Y→B, Z→C (with shift 3). Named after Julius Caesar who reportedly used a shift of 3 for military messages.

Shifted letter = (Original position + Shift) mod 26. With shift=3: A→D, B→E, C→F, ..., X→A, Y→B, Z→C

  • Shift 1: CAT → DBU
  • Shift 3: HELLO → KHOOR
  • Shift 5: APPLE → FUUQJ

How to recognize it

  • All letters shifted by the same amount
  • Key shows consistent pattern (A→D, B→E means shift 3)
  • Wraps around at Z back to A

Common mistakes

  • Forgetting to wrap around (Y+3 should be B, not beyond Z)
  • Shifting in the wrong direction for decoding
  • Not identifying the shift value from given examples

Step-by-step walkthrough

Encode 'HELLO' using a Caesar cipher with shift 3

  1. H is the 8th letter. Add 3: position 11 = K
  2. E is the 5th letter. Add 3: position 8 = H
  3. L is the 12th letter. Add 3: position 15 = O
  4. L again: position 15 = O
  5. O is the 15th letter. Add 3: position 18 = R

Answer: KHOOR

Practice guidance

Coding & Decoding

Advertisement