Skip to content

Security Cluster

From Caesar to Vigenère: A History of Classical Ciphers

Published April 11, 2026 · 11 min read

Two thousand years ago, Julius Caesar shifted every letter of a message three places down the alphabet to hide it from his enemies. He was not the first to use a cipher — scribes in ancient Mesopotamia had been doing it for at least a thousand years before him — but his method was simple enough to explain and survive in the historical record, which is why the Caesar cipher carries his name. The technique took about fifteen minutes for a literate Roman to break, if they happened to be thinking about it.

The history of classical ciphers is the history of an arms race. Every scheme, once considered unbreakable, fell to a clever insight from the next generation. Studying them now is not about learning to encrypt anything — nobody uses Caesar in production — but about understanding why modern cryptography looks the way it does. Every design decision in AES or ChaCha20 is an answer to a weakness that a classical cipher exposed.

The substitution family

A substitution cipher replaces each letter of the plaintext with another letter according to a rule. The Caesar cipher is the simplest possible substitution: a shift by a fixed number of positions. "HELLO" with a shift of three becomes "KHOOR". The key is the shift value, and there are only 25 possible keys for the Latin alphabet — you can try them all in a minute.

Experiment with it yourself using Caesar Cipher. Type a sentence, pick a shift, watch the output. Try to decode a ciphertext without knowing the shift: it is easier than you think, because English has a distinctive letter frequency. E is the most common, followed by T, A, O, I, N. If you see a cipher in which the most frequent letter is H, the shift is probably 3. If it is W, the shift is 18. Frequency analysis breaks any monoalphabetic substitution in seconds.

The famous special case of Caesar with shift 13 is ROT13, which has a quirky property: applying it twice returns the original text, because 13 + 13 = 26. That makes it self-inverse and painlessly reversible by hand. ROT13 was never meant as real security. It is used to hide spoilers in forum posts and obscure joke punchlines, and it does that job well precisely because readers can toggle it on demand. Try it in ROT13 Encoder — encode a sentence, then feed the output back in and watch it invert itself.

Atbash: the ancient reversal

Atbash is older than Caesar. It appears in the Hebrew Bible, used occasionally by scribes to encode place names. The rule is trivial: A maps to Z, B maps to Y, C maps to X — a mirror of the alphabet. No key. Anyone who knows the trick can decode immediately.

Why bother teaching this? Because it illustrates the difference between a cipher (an algorithm) and a key (the secret parameter). Atbash has zero key space — once you know the method, you know everything. A real cipher separates the algorithm from the secret, so that publishing the algorithm does not weaken it. This is Kerckhoffs's principle, stated in 1883: a cryptosystem should be secure even if everything about the system, except the key, is public knowledge. Modern cryptography lives by this rule. Atbash violates it.

Atbash Cipher lets you experiment with the transformation. Run your name through it and see what you get — there is no key to choose, and the result is the same for anyone using the same algorithm, which is precisely why it is not security.

The affine cipher and modular arithmetic

An affine cipher is Caesar's older sibling with one more degree of freedom. Instead of just adding a constant, it applies a linear function modulo 26: E(x) = (a·x + b) mod 26. The key is the pair (a, b). The constant a must be coprime to 26 for the cipher to be reversible, which limits the choices to 12 valid multipliers × 26 shifts = 312 possible keys. Still trivially small.

The affine cipher's interest is not cryptographic — it is pedagogical. It introduces the idea that encryption can be expressed as an algebraic function and that decryption is the inverse of that function. This framing was crucial for nineteenth-century mathematicians trying to understand cryptography rigorously, and every modern block cipher is, at its heart, a very complicated algebraic function with an inverse that is easy to compute only if you know the key. Affine Cipher lets you pick both parameters and see how a tiny change in (a, b) completely scrambles the output.

Vigenère and three centuries of false security

The Vigenère cipher, published in 1586 by Giovan Battista Bellaso (and misattributed to Blaise de Vigenère for centuries), was the first widely adopted cipher that resisted frequency analysis. The insight was simple: instead of shifting every letter by the same amount, use a keyword to shift each letter by a different amount. "HELLO" with the key "CAT" shifts H by C (2), E by A (0), L by T (19), L by C (2), O by A (0), producing "JERNO". The same plaintext letter maps to different ciphertext letters depending on its position, which smears out the letter frequency distribution and defeats the naive attack.

For 300 years, Vigenère was called le chiffre indéchiffrable — the unbreakable cipher. Then, in the mid-1800s, Friedrich Kasiski (a retired Prussian officer) and, independently, Charles Babbage (of analytical engine fame) figured out how to break it. The attack has two steps. First, find repeated sequences in the ciphertext. Because natural language has repetitive bigrams and trigrams, any sequence that appears twice in the plaintext at a distance that is a multiple of the key length will produce the same ciphertext sequence. The distance between the repetitions is therefore a multiple of the key length. Collect enough repetitions and the key length pops out as the greatest common divisor of the distances.

Second, once you know the key length, slice the ciphertext into that many interleaved columns — each column is a Caesar cipher with a fixed shift. Solve each column by frequency analysis. The full key is reconstructed, and the message is plaintext. This attack reduced a 300-year-old fortress to a weekend puzzle for anyone who read Kasiski's paper.

Experiment with it using Vigenère Cipher. Encode a few sentences with different key lengths, then compare outputs. You can feel the Kasiski attack working — short keys leave obvious patterns, longer keys look more random. The lesson for modern cryptography is that any statistical pattern in the output is a hole the attacker will crawl through. Modern ciphers are designed so that the output is statistically indistinguishable from random noise, regardless of the input.

Playfair and bigram statistics

The Playfair cipher, invented by Charles Wheatstone in 1854 and promoted by Lord Playfair, was used by British forces in the Boer War and both World Wars. Instead of replacing single letters, it operates on pairs. The key is a 5×5 grid filled with the letters of a keyword (with I and J combined, since 25 squares is convenient). To encrypt a pair of letters, you look them up in the grid and apply a rule based on whether they are in the same row, column, or form a rectangle.

Playfair breaks simple frequency analysis because single-letter statistics no longer apply — the cipher works on digraphs (two-letter combinations), and the distribution of digraphs is flatter than that of single letters. It is still vulnerable to digraph frequency analysis, which was not a well-known technique in 1854 but became routine by the early 20th century. Modern cryptographers would break it over lunch.

The concept still matters: modern block ciphers work on blocks of 128 bits (not one letter, not two — 16 bytes at a time), which pushes the statistical analysis bar far higher. Playfair Cipher lets you build the key grid interactively and watch how pairs of letters get transformed. Pay attention to which pairs end up in the same row vs different rows — that is where the structure leaks.

Transposition: rearranging instead of replacing

A transposition cipher does not replace letters at all. It rearranges them. The Rail Fence Cipher writes the plaintext in a zigzag pattern across N rows and then reads off the rows in order. "HELLO WORLD" on three rails becomes H-O-L, E-L-W-R-D, L-O, concatenated as HOLELWRDLO. It is easily broken — you just try every number of rails until the plaintext emerges — but it introduces the idea that rearrangement is a legitimate cryptographic operation.

This matters because modern block ciphers use permutation layers. AES has a step called ShiftRows that shifts the rows of its internal state matrix, which is a transposition. ChaCha20 has quarter-round mixing that permutes word positions. The lesson from rail fence is that mixing the order of bits is part of a good diffusion strategy — and the classical ciphers were the first to articulate that.

Bacon's cipher and early steganography

Francis Bacon devised a cipher in 1605 that is fascinating because it is barely a cipher at all. Each letter of the plaintext is encoded as a five-letter pattern of A's and B's — essentially five bits per character. Then the A's and B's are hidden in a cover text using two fonts or styles. The recipient reads the font pattern, not the words, to recover the message.

This is steganography — hiding the existence of a message — rather than cryptography in the strict sense. The core idea, that information can be embedded in the channel itself rather than in the explicit data, runs through modern covert channels, digital watermarking, and (more benignly) ultrasonic ad-tracking beacons. Bacon Cipher lets you encode text into the A/B representation and see how each letter maps to its 5-bit code. The correspondence to binary is not a coincidence — Bacon was thinking along the same lines as the pioneers of information theory, three hundred years early.

What the classical era taught us

Three lessons from classical cryptography are still operative:

  • Statistical structure is a hole. Any pattern the attacker can detect is exploited. Modern ciphers produce output that looks uniformly random.
  • Key size matters. Caesar had 25 possible keys. AES-256 has 2^256. The difference is not a matter of degree; it is whether brute force is possible.
  • Kerckhoffs's principle. Publish the algorithm, keep only the key secret. If your security depends on the attacker not knowing how the cipher works, the cipher has already failed.

For further reading, the classics are David Kahn's The Codebreakers (a thorough history) and Simon Singh's The Code Book (more accessible). Online, the Britannica cryptology entry is a good one-page overview, and the Wikipedia history of cryptography is surprisingly well-sourced.

Related pillar guide

This cluster sits under our security pillar. For the modern half — hashing, encryption, OWASP, and the full toolkit — see Web Security Tools: A Beginner's Masterclass.

FAQ

Can I use a classical cipher for anything real?

No. Not for security. They are interesting as puzzles, as educational examples, and as the setup for modern techniques, but for any real-world confidentiality you need authenticated encryption with modern primitives — AES-GCM or ChaCha20-Poly1305. Use a library, not a classical cipher implementation.

Why is ROT13 still in use?

Because it is not security — it is a courtesy. It hides a punchline or spoiler from someone who would otherwise read it accidentally, and lets them decide to reveal it by applying the transform. That is a legitimate use case that modern cryptography does not address.

Was the Vigenère cipher really unbreakable for 300 years?

It was widely believed to be, yes. The Kasiski attack was published in 1863. Babbage had discovered the technique earlier but did not publish. Before Kasiski, cryptanalysts attacked Vigenère with ad-hoc methods and sometimes succeeded on short messages, but there was no general technique.

What is the simplest way to break a substitution cipher by hand?

Frequency analysis. Count the letters of the ciphertext. The most common ciphertext letter probably maps to E (the most common English letter). Look for one-letter words (A or I), three-letter words (THE, AND), apostrophes (almost always contractions), and double letters. Filled in iteratively, the plaintext usually appears within minutes for any message longer than 200 characters.

Are there any classical ciphers that are still hard to break?

The one-time pad, in the strict sense, is perfectly secure — Claude Shannon proved it mathematically in 1949. It is classical in the sense of being simple (XOR the plaintext with a truly random key of the same length) but impractical for most use cases because the key must never be reused. Every "one-time pad" that reused keys fell to cryptanalysis. The concept still matters in modern information theory.

Closing thought

Classical ciphers are a museum of bad ideas that taught us everything. Every clever attack — frequency analysis, Kasiski examination, digraph statistics — became a design constraint for the next generation, until we arrived at AES and ChaCha20, where every known cryptanalytic technique fails. Understanding how we got here makes modern cryptography less like magic and more like engineering. Spend an afternoon encoding sentences with Caesar and breaking them by hand, and you will never look at a signed JWT the same way again.