Skip to main content
Cryptography

The Atbash cipher: the ancient code that decodes itself

Older than the Caesar cipher and stranger too — Atbash mirrors the alphabet so that encrypting twice gets you back where you started. Here's how the self-inverse cipher works.

Thien Nguyen
By Thien Nguyen
Updated June 20, 2026 · 2 min read

Before Caesar was shifting letters, Hebrew scribes were flipping them. The Atbash cipher is one of the oldest substitution ciphers known — it appears in the Hebrew Bible — and it has a property that still delights anyone who meets it: it is its own inverse. Encrypt a message twice and you're holding the original again.

Mirror the alphabet

Atbash works by reversing the alphabet onto itself. The first letter maps to the last, the second to the second-to-last, and so on:

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

So A ↔ Z, B ↔ Y, C ↔ X. The name itself encodes the rule: A-T-B-Ash pairs the first Hebrew letter (Aleph) with the last (Taw), the second (Beth) with the second-to-last (Shin).

Because the mapping is a mirror, there's no direction to remember. HELLO encrypts to SVOOL, and SVOOL encrypts right back to HELLO. The same function does both jobs.

Why "self-inverse" is the interesting part

Most ciphers have a distinct encrypt and decrypt step. Atbash collapses them into one, which makes it a self-inverse (or involutory) transformation — apply it twice and the two mirrors cancel out.

This isn't just a party trick. Self-inverse operations show up all over computing: XOR-ing data with the same key twice restores it, and that exact property powers everything from simple obfuscation to the internals of real block ciphers.

How secure is it? (It isn't.)

Atbash has a keyspace of exactly one. There's a single possible mapping, so there's nothing to guess — if you know it's Atbash, you've already decoded it. Like the Caesar cipher, its letter-frequency structure also survives untouched, so even someone who doesn't know the scheme cracks it with basic frequency analysis.

It was never really about secrecy. For the scribes it was likely a scribal device or a way to mark a word as special; today it's a puzzle-maker's favourite and a neat first lesson in substitution.

Playing with substitution ciphers

Atbash is a fixed cousin of the shift ciphers, and the fastest way to feel how substitution ciphers behave is to play with an adjustable one. Our Caesar Cipher tool lets you slide the shift and watch a substitution scramble and unscramble text live in your browser — the same family of idea, with a dial you can turn.

Both ciphers teach the same humbling truth: a code that's clever is not the same as a code that's secure. That gap is the entire history of cryptography.

References

Primary documentation and specifications checked when this article was last updated.

CryptographyCiphersHistory

Related articles

All articles