Skip to main content
Basic Classic Symmetric Beginner

The Atbash Cipher

Learn about the Atbash cipher, one of the oldest known substitution ciphers, where each letter is mirrored to the opposite end of the alphabet.

PL
Pashalis Laoutaris
August 21, 2026
11 min read

Interactive Atbash Cipher Visualizer

🔐 Atbash Cipher Visualizer

5
Enter text and click a button to start!
HELLO

The Atbash Cipher: Mirroring the Alphabet

Introduction

The Atbash cipher is one of the oldest known encryption techniques, predating even the Caesar cipher. Originally devised for the Hebrew alphabet, it works by a simple rule: reverse the alphabet, then substitute each letter of the plaintext with its mirror image. It’s a monoalphabetic substitution cipher with a twist that makes it unique among classic ciphers: it requires no key, and encryption and decryption are the exact same operation.

Table of Contents

History and Origins

Atbash originated as a substitution cipher for the 22-letter Hebrew alphabet, where it gets its name: A-T-B-A-S-H, a combination of the first letter (Aleph), the last letter (Tav), the second letter (Bet), and the second-to-last letter (Shin). The earliest attested use appears in the Hebrew Bible itself, notably in the Book of Jeremiah, where the word “Sheshakh” is an Atbash-encoded reference to Babylon (“Bavel”). A second, equally well-known biblical example appears later in the same book: “Leb-kamai” (Jeremiah 51:1) is an Atbash rendering of “Kasdim,” the Hebrew term for the Chaldeans.

When adapted to the 26-letter Latin alphabet, the same mirroring principle applies directly: A becomes Z, B becomes Y, and so on to the middle of the alphabet, where M becomes N and N becomes M.

How the Atbash Cipher Works

Atbash maps each letter to the letter at the same distance from the opposite end of the alphabet. As a single formula, matching the style used throughout this series:

E(x) = 25 - x

(No modulo is needed here: unlike Caesar or Affine’s mod 26, subtracting a value from 0-25 out of 25 always lands back in the 0-25 range on its own.)

Encryption/Decryption Process:

  1. For each letter in the text, find its position in the alphabet (A=0, B=1, …, Z=25).
  2. Subtract that position from 25 to get the mirrored position.
  3. Replace the original letter with the letter at the mirrored position.

Full mapping:

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

Example: “HELLO” → “SVOOL”

There’s no key to choose, no shift value to remember. The mapping is completely fixed. This also means there is exactly one possible Atbash “key,” compared to the Caesar cipher’s 25. Non-letter characters (spaces, punctuation, digits) aren’t part of the 0-25 mapping at all. Conventionally, and in the visualizer above, they’re stripped out before the transformation runs, the same treatment used throughout this series.

Atbash is, in fact, not really a separate cipher mathematically. It’s a special case of the Affine cipher’s general formula E(x) = a·x + b mod 26, with a = 25 (equivalent to -1) and b = 25. Plug those in and you get E(x) = 25·x + 25 mod 26 = -x + 25 mod 26 = 25 - x, exactly the rule above.

Interactive Visualizer

Try it yourself with the visualizer above. Enter any text and watch each letter mirror across the alphabet in real time. Because Atbash is symmetric, running the transformation on the output gives you back the original text.

Why Atbash Is Its Own Inverse

Atbash has a mathematically elegant property: it is an involution, meaning applying it twice returns the original input. If a letter at position p maps to position 25 - p, then applying the same rule again gives 25 - (25 - p) = p, right back where it started.

Concretely: H sits at position 7. Applying the rule once, 25 - 7 = 18, which is S. Applying the exact same rule to S (position 18) gives 25 - 18 = 7, which is H again. H → S → H, with no separate “undo” step required.

This means Atbash has no separate “encrypt” and “decrypt” modes. The same operation does both. That’s why the visualizer above only has a single “Transform” button rather than the Encrypt/Decrypt pair you’ll see on the Caesar cipher visualizer.

Pros and Cons Analysis

Advantages Disadvantages
Simplicity: Trivial to compute by hand, with no key management required No Key Space: With zero variability, there is nothing to brute-force but also nothing to configure. Anyone who knows it’s Atbash can decode it instantly
Symmetric Operation: Encryption and decryption are identical, simplifying implementation Frequency Analysis: Like all monoalphabetic substitution ciphers, it preserves the letter-frequency distribution of the source language, making it trivially breakable
Historical/Educational Value: A clean example of a self-inverse substitution cipher and an entry point into biblical cryptography Zero Modern Security: Offers no meaningful protection against any adversary with basic cryptanalysis knowledge
Fast Manual Computation: The mirrored pairs (A-Z, B-Y, …) are easy to memorize Single Fixed Mapping: Because there’s only one possible substitution, it’s immediately recognizable once suspected

Cryptanalysis and Breaking the Atbash Cipher

Breaking Atbash barely qualifies as cryptanalysis. There is nothing to search for. Since the substitution alphabet is completely fixed, “breaking” it is just a matter of recognizing that Atbash was used and applying the well-known A↔Z, B↔Y mapping. Unlike the Caesar cipher, there isn’t even a keyspace to brute-force. The mapping table itself is the entire “key,” and it’s public knowledge. Once Atbash is suspected at all, there’s no further computation involved: no candidate keys to test, no statistics to gather, just a direct table lookup for every letter.

If the cipher’s identity is unknown, standard frequency analysis still applies. Atbash is a monoalphabetic substitution, so it preserves the source language’s letter-frequency profile just as the Caesar cipher does. Comparing ciphertext letter frequencies against expected English frequencies quickly reveals the pattern.

Atbash vs. Caesar

Both are classic monoalphabetic substitution ciphers, but they differ in one key way:

  • Caesar cipher: A family of 25 possible shifts, a keyed cipher, even if the key space is small.
  • Atbash cipher: Exactly one fixed mapping, effectively a keyless cipher.

Both are trivial to break in practice, but the comparison isn’t quite a wash. If an attacker doesn’t already know which cipher was used, Caesar at least forces them to try roughly 25 candidate shifts before landing on the right one. Atbash offers nothing to try at all: there’s only ever one possible mapping. In that narrow sense, Atbash is the weaker of the two. It also makes for a useful teaching contrast. It demonstrates that not every substitution cipher needs a key to be classified as a cipher, and it introduces the concept of an involution, a building block that reappears in modern cryptography. XOR-based stream ciphers, for example, are also involutions.

Modern Relevance

Atbash has no place in modern security systems, but it remains useful as:

  • A teaching tool for introducing substitution ciphers and the concept of self-inverse functions before moving to keyed ciphers like Caesar and Vigenère.
  • A puzzle and wordplay device, still occasionally used in puzzle hunts, escape rooms, and recreational cryptography.
  • A historical artifact, illustrating that cryptographic thinking (obscuring a message through systematic letter substitution) dates back millennia.
  • An early example of involutory design, an idea that resurfaces in far more sophisticated form in the Enigma machine’s reflector. Its fixed, self-inverse wiring is exactly why a single Enigma machine can both encrypt and decrypt without a mode switch, the same core property Atbash demonstrates at its simplest.

Python Implementation

The whole cipher is one line of arithmetic per letter, 25 - x, applied with no key and no mode switch:

def atbash_transform(text):
    """Encrypts and decrypts: the same operation does both."""
    text = ''.join(c for c in text.upper() if c.isalpha())
    return ''.join(chr(ord('Z') - (ord(c) - ord('A'))) for c in text)

if __name__ == "__main__":
    plaintext = "HELLO"

    ciphertext = atbash_transform(plaintext)
    recovered = atbash_transform(ciphertext)

    print(f"Plaintext:  {plaintext}")
    print(f"Ciphertext: {ciphertext}")
    print(f"Recovered:  {recovered}")

This prints HELLOSVOOLHELLO, calling the identical function both times, exactly the involution property described above.

Limitations

There’s very little to this implementation, which is itself the point:

  • English letters only, formatting is lost. Spaces, punctuation, and case are stripped before the transform runs, so the original message’s formatting doesn’t survive a round trip.
  • No mode parameter, because none is needed. Unlike every other cipher function in this series, there’s no mode="encrypt" argument here; adding one would just be dead code, since both directions are identical.
  • No key to get wrong, but also none to configure. There’s nothing to validate or misconfigure, which is exactly why Atbash offers no flexibility either.
  • Not intended for real security. As the Cryptanalysis section above notes, recognizing Atbash is instant and requires no computation at all; this code exists to demonstrate the involution property, not to protect anything.

Conclusion

The Atbash cipher is about as simple as encryption gets: a single, fixed mirror-image mapping across the alphabet, with no key to manage and no decision to make beyond “is this Atbash or not?” Its value today is entirely educational. It’s a clean first example of a self-inverse substitution cipher, and a stepping stone toward understanding the keyed substitution ciphers, like Caesar and Vigenère, that followed it historically.

FAQ

What is the Atbash Cipher?

Atbash is a substitution cipher that replaces each letter with its mirror image in the alphabet (A↔Z, B↔Y, and so on). It originated with the Hebrew alphabet and has no configurable key.

Is Atbash the same as ROT13?

No. ROT13 is a Caesar shift of 13 positions (A→N, B→O, …), while Atbash is a full alphabet reversal (A→Z, B→Y, …). Both happen to be involutions (applying them twice returns the original text), but they use different mappings.

Why doesn’t Atbash need a decryption step?

Because Atbash is an involution: mapping a letter at position p to position 25 - p and then repeating the operation returns p again. The same transformation encrypts and decrypts.

Is the Atbash Cipher secure?

Not remotely. It has no key space, preserves letter frequencies, and is immediately recognizable once suspected. It offers no protection against any real adversary.

Where does the name “Atbash” come from?

It’s an acronym built from the first, last, second, and second-to-last letters of the Hebrew alphabet: Aleph, Tav, Bet, Shin. That reflects the cipher’s letter-pairing rule.

Does Atbash work on other alphabets?

Yes. The mirroring idea works on any ordered alphabet, regardless of length or whether that length is even or odd. For an alphabet of size n, the rule generalizes to E(x) = (n - 1) - x. With an odd-length alphabet, the single middle letter has nowhere else to map to and simply encrypts to itself. With an even-length alphabet, like Hebrew’s 22 letters or the 26-letter Latin alphabet used throughout this article, every letter pairs off with a different one and there’s no such fixed point.

References

  1. Wikipedia. “Atbash.” Available at: https://en.wikipedia.org/wiki/Atbash

  2. GeeksforGeeks. “Atbash Cipher.” Available at: https://www.geeksforgeeks.org/atbash-cipher/

  3. Practical Cryptography. “Atbash Cipher.” Available at: http://practicalcryptography.com/ciphers/atbash-cipher/