> MIRROR CIPHER
The idea in plain English: Imagine holding a message up to a mirror. Everything is reversed left-to-right, AND each letter is reflected: A looks like Z, B looks like Y, C looks like X, and so on. This cipher does exactly that — it reverses the string, then applies the Atbash substitution (A→Z, B→Y, C→X...). To decode, you do the same thing: Atbash each letter, then reverse the order.
Why this really exists: The Atbash cipher (the letter-mapping part) dates back to ancient Hebrew, around 500 BC. It appears in the Bible (the book of Jeremiah has Atbash- encoded names). It's the simplest possible substitution cipher — the alphabet is just folded in half. Combined with reversal, it's a nice two-step mental puzzle that's easy for humans to solve with pen and paper.
▸ Concrete Example
Ciphertext: "SVOOL"
S → H (S is 18th letter, 26-18+1=8 → H)
V → E (V is 21st → 26-21+1=5 → E)
O → L (O is 15th → 26-15+1=11 → L)
O → L
L → O
After Atbash: "HELLO"
Step 2 — Reverse: "HELLO" → "OLLEH"
Wait — let me think again. Which comes first?
Correct decoding: Atbash first, then reverse.
"SVOOL" → Atbash → "HELLO" → Reverse → "OLLEH"
Nope — the answer depends on the encoding order. If the encoder reversed first then Atbashed, the decoder Atbashes first then reverses. Both work symmetrically.
Try both orders — one will produce readable text!
The Atbash mapping is: A↔Z, B↔Y, C↔X, D↔W, E↔V, F↔U, G↔T, H↔S, I↔R, J↔Q, K↔P, L↔O, M↔N.
▸ How to Decode (Step by Step)
1. For each letter in the ciphertext, apply Atbash: letter → opposite end of alphabet
2. Reverse the resulting string
3. If that doesn't make sense, try reversing first then Atbashing
return chr(ord('Z') - (ord(c) - ord('A'))) if c.isalpha() else c
# Option A: Atbash then reverse
word = ''.join(atbash(c) for c in ciphertext)[::-1]
# Option B: Reverse then Atbash
word = ''.join(atbash(c) for c in ciphertext[::-1])
▸ Real-World Applications
- Ancient cryptography: Atbash appears in the Hebrew Bible (Book of Jeremiah)
- Pen-and-paper puzzles: Easy enough for anyone to solve with just a pencil
- Teaching substitution: A perfect first example of "systematic replacement" in crypto courses
- ROT13 variant: Sometimes used in online forums alongside ROT13 for mild obfuscation