Skip to main content

The Atbash Cipher: How Reversing the Alphabet Hides (and Reveals) Text

A plain-English guide to the Atbash cipher: how mirroring the alphabet works, why one button encodes and decodes, its ancient Hebrew roots, and CTF uses.

Published By Li Lei
#atbash cipher #classical cryptography #ctf #encoding #substitution cipher

The Atbash Cipher: How Reversing the Alphabet Hides (and Reveals) Text

Atbash is the cipher you can run in your head once you understand one sentence: write the alphabet, then write it again backwards underneath, and swap. A swaps with Z, B with Y, C with X, and you keep folding inward until M and N meet in the middle. There is no key, no shift number, nothing to configure. That radical simplicity is exactly why Atbash has survived for more than two thousand years as a puzzle, a teaching example, and a recurring trick in capture-the-flag challenges.

This post walks through how the mapping works, why the same operation both scrambles and unscrambles text, where the cipher came from, and where it actually shows up today. If you just want to throw text at it, the Atbash cipher encoder and decoder handles the substitution live in your browser.

Each letter maps to its mirror

The whole cipher fits in a single rule: pair the first letter of the alphabet with the last, the second with the second-to-last, and so on. Concretely:

  • A ↔ Z
  • B ↔ Y
  • C ↔ X
  • D ↔ W
  • ... and onward until M ↔ N close the list in the center.

To transform any letter you find it on one side of a pair and write down the letter on the other side. That is the entire algorithm. Notice what is missing compared to a Caesar shift: there is no "move forward by 3" or "rotate by 13." Every letter travels a different distance. A moves 25 positions to reach Z, while M only moves one position to reach N. The cipher is a reflection, not a slide, and that distinction matters more than it first appears.

Only the 26 Latin letters get touched. Digits, spaces, punctuation, accented characters like é, Chinese and other CJK text, and even emoji pass straight through in their original positions. Case is preserved too, so an uppercase G becomes an uppercase T and a lowercase g becomes a lowercase t. If you mirror Hello, World 2026! you get Svool, Dliow 2026! with the comma, the space, the year, and the exclamation mark all sitting exactly where they started.

Encrypting and decrypting are the same operation

Here is the property that makes Atbash genuinely elegant: it is its own inverse. Cryptographers call this self-reciprocal or self-inverse. Because A maps to Z, Z must map back to A using the identical rule. There is no separate "decode direction" to compute. Run any message through Atbash once and it scrambles; run that scrambled output through Atbash a second time and you land back on the original text, character for character.

That is why a good Atbash tool has one button instead of an encode mode and a decode mode. Feeding ciphertext in is the same as feeding plaintext in. The machine does not know or care which one you handed it.

It is worth contrasting this with ROT13, which is also self-inverse. ROT13 only gets that property by coincidence: rotating 13 places forward in a 26-letter alphabet is the same as rotating 13 places back, because 13 is exactly half of 26. Atbash is self-inverse by its very nature as a mirror, independent of how long the alphabet happens to be. Reflect a list twice and you always return to the start, whether the list has 26 entries or 260.

A worked example: encoding "PUZZLE"

Let me run a real word through it so the mechanics are concrete. Take the word PUZZLE and go letter by letter:

  • P is the 16th letter. Its mirror is the 11th from the end, which is K.
  • U is the 21st letter. Its mirror is F.
  • Z is the last letter. Its mirror is the first, A.
  • Z again becomes A.
  • L is the 12th letter. Its mirror is O.
  • E is the 5th letter. Its mirror is V.

So PUZZLE becomes KFAAOV. Now apply the rule a second time to KFAAOV: K returns to P, F to U, A to Z, A to Z, O to L, V to E, and you are back to PUZZLE. One operation in both directions, no second algorithm needed. That round trip is the cleanest way to convince yourself the cipher really is its own inverse.

Where Atbash came from

The name itself encodes the method. Atbash is built from the first, last, second, and second-to-last letters of the Hebrew alphabet: aleph–taw, beth–shin, spelled out as aleph-taw-beth-shin and contracted to ATBaSH. It is a Hebrew cipher describing a Hebrew swap, applied originally to the 22 letters of that alphabet rather than the 26 of Latin.

The cipher's most famous appearances are in scripture. Certain names in the Hebrew Bible were written in Atbash form, which is why "Sheshach" in the book of Jeremiah is widely read as an Atbash spelling of "Babel" (Babylon). Whether that was meant to conceal, to decorate, or simply as wordplay is still debated, but it makes Atbash one of the oldest documented substitution ciphers we have. Scribes were folding the alphabet in half centuries before anyone wrote down a formal theory of cryptography.

Atbash today: puzzles, CTFs, and why it is not security

Atbash has no place protecting real data, and that was never its job. There is exactly one possible mapping. Nothing to brute force, no key to keep private. Anyone who recognizes that a string is Atbash decodes it on sight, and even someone who has never heard the name can crack it with basic frequency analysis or a single lucky guessed word. Treat it as a puzzle, never as protection for a password, a token, or anything that has to stay private.

Where it does earn its keep is in games and teaching. In capture-the-flag competitions, Atbash is the standard second thing to try after ROT13 when a string is obviously a simple substitution but ROT13 produces garbage. Because there is no key to grind through, you either get readable text immediately or you move on. Escape rooms and puzzle hunts love it for the same reason: a designer can hide the location of the next key behind a mirror that players solve with a pencil and the alphabet written forwards and backwards, no key card required.

I keep an Atbash tool open during CTF nights for exactly this reflex. The first time it paid off, I had a flag that looked like noise and ROT13 left it just as unreadable. On a hunch I pasted it through the mirror, and the cleartext popped out on the first pass. It took about three seconds and saved me from over-thinking a deliberately trivial stage. That is the entire value of the cipher in modern use: it is fast to test and fast to rule out.

If you want to see how a mirror differs from a slide, run the same sentence through a Caesar cipher encoder right after Atbash. The Caesar version moves every letter the same distance; the Atbash version reflects, so each letter lands somewhere different. Putting the two side by side is the quickest way to feel why "shift" and "mirror" are genuinely different ideas, and it makes a great classroom contrast.

The takeaway

Atbash is the cipher of a single rule. Mirror the alphabet, A with Z, B with Y, all the way to M with N, and you have everything. The same operation encodes and decodes because the mapping is its own inverse, so running text through twice always returns the original. Born in the Hebrew alphabet and preserved in ancient texts, it now lives mostly in puzzles and CTF challenges, where its weakness as a cipher is precisely what makes it useful as a quick, key-free reflection. Type a word, watch it flip, run it back, and the whole idea clicks.


Made by Toolora · Updated 2026-06-13