Ciphers · Keys · Hashes

Cryptography Explorer

Encrypt / Hash Learn Cryptography

Learn · Classical ciphers

The story of Caesar & Vigenère — told on your own message.

Read two thousand years of secret writing, part by part. Set a message and keyword below: every section pairs its explanation with a live figure of your letters being shifted at exactly that step, looping on its own as you read (pause any of them with ⏸). Dotted-underlined terms pop up a quick demo of that concept, and any "in the lab" link drops you into the full lab at that stage.

Letters only; the key must be shorter than the message. Every figure and every number in the prose recomputes from these values.

Part 1 — The idea

Replacing letters by rule

Strip away the machinery and every classical cipher is one move: take each letter of a message and replace it with another letter, following a rule the sender and receiver both know. The rule is the secret. Anyone who has the rule can undo the swap; anyone without it sees noise. That single move is called substitution, and it carried secret writing for two thousand years.

To make the rule precise, treat letters as numbers. Number the alphabet A = 0, B = 1, and so on up to Z = 25, and suddenly a substitution is not a lookup table — it is arithmetic. "Replace each letter with the one three places later" becomes "add 3." Arithmetic can be written down, reasoned about, and, as you will see, attacked.

Your message is the running example for everything below. Every ciphertext on this page is computed live from it, so when the text says a letter moves, you can watch your own letter move.

Part 2 — Julius Caesar's cipher

Add three, wrap around

The Roman historian Suetonius, writing about a century and a half after the fact, reports that Julius Caesar protected his private correspondence by shifting every letter three places down the alphabet — A became D, B became E, and X, Y, Z wrapped back around to A, B, C. The recipient shifted three places back and read the message. Whether Caesar's enemies ever broke it, Suetonius does not say; most of them likely could not read Latin, let alone shifted Latin.

That is the whole cipher. Pick a shift — the key — and add it to every letter, wrapping past Z. Any shift works, not just Caesar's three, which is why the general form is called a shift cipher: twenty-five usable keys, one rule.

On your message with a shift of , every letter slides the same distance and becomes . The words dissolve, and to anyone without the shift it looks like the secret is safe.

Shift your own message in the lab

Part 3 — The fingerprint that survives

Language leaks through

The shift cipher stood for roughly nine hundred years before someone wrote down how to break it. In 9th-century Baghdad, the polymath al-Kindi — philosopher, mathematician, physician — produced A Manuscript on Deciphering Cryptographic Messages, the oldest surviving description of frequency analysis. His observation: letters in any language are not used equally, and no substitution can hide that.

In a long stretch of English, E dominates, with T and A close behind, while Q, X, and Z barely appear. Count the letters of a shift-cipher ciphertext and the same lopsided histogram stares back at you — every bar slid sideways by the shift, none of them flattened. Find the tallest bar, assume it is E, and the key falls out. The shift moves the fingerprint; it does not erase it.

And even without statistics, the shift cipher has a cruder problem: there are only twenty-five possible keys. Write out all twenty-five decryptions of a short ciphertext and one of them is plainly English. That is brute force, it takes minutes with a pencil, and it needs no insight at all.

See the letter-frequency fingerprint in the lab

Part 4 — Many alphabets: the Vigenère cipher

A different shift for every letter

If one shift leaks the fingerprint, use many. In 1553 the Italian cryptographer Giovan Battista Bellaso published exactly that: choose a keyword, and let each of its letters name a different shift. The idea was later misattributed to the French diplomat Blaise de Vigenère — who did real work on related ciphers — and his name stuck to Bellaso's invention so firmly that no one has managed to peel it off since. History is not always fair about credit.

The mechanism: write the keyword under the message, repeating it as many times as needed so every message letter has a key letter beneath it. Your keyword has letters, so it lays down a repeating pattern of different shifts — each key letter's number, A = 0 through Z = 25, is the distance its column slides.

Ci = (Mi + Ki) mod 26
Each ciphertext letter is the message letter plus its key letter, wrapped back into the alphabet by the .

Now the same plaintext letter encrypts differently depending on where it lands. An E under one key letter becomes one thing; the next E, under a different key letter, becomes another. The frequency histogram that betrayed Caesar gets smeared across as many alphabets as the keyword has letters, and al-Kindi's method — applied naively — reads only mush.

Europe's codebreakers agreed. The cipher earned the name le chiffre indéchiffrable — the indecipherable cipher — and held that reputation for roughly three hundred years, carrying diplomatic and military traffic well into the 19th century.

Line your key up under your message

Part 5 — Lock and unlock

Add to encrypt, subtract to decrypt

Encryption walks the message one letter at a time: take the message letter's number, add the key letter's number below it, wrap past 25, and write down the letter you land on. Do that for every position and becomes . No letter's disguise depends on any other letter — each position is its own little Caesar cipher, keyed by its own key letter.

Encrypt your message letter by letter

Decryption is the same walk in reverse. The receiver lays the same keyword under the ciphertext and subtracts instead of adds. When the subtraction dips below zero — a C minus a K, say — the mod 26 wrap adds the alphabet back, the mirror of the wrap that happened on the way in.

Mi = (Ci − Ki) mod 26
Subtract the same key letter that was added, wrap back into range, and the plaintext letter reappears.

Run it on your ciphertext and comes back as — the round trip closes exactly, because subtraction undoes addition position by position. That symmetry is the defining shape of a symmetric cipher: one shared key, used forward to lock and backward to unlock. AES works the same way; only the arithmetic got harder.

Decrypt it back and watch the message return

Part 6 — How it fell

The repeating key betrays itself

The indecipherable cipher fell twice, to two men working independently. Charles Babbage — better remembered for his computing engines — broke it around 1854, likely spurred by British interests in the Crimean War, but never published. Nine years later, in 1863, the Prussian officer Friedrich Kasiski published the method openly, and it carries his name: the Kasiski examination.

The crack runs through the key's one weakness — it repeats. When a common fragment of plaintext happens to line up with the same stretch of the repeating keyword twice, it encrypts to the same ciphertext fragment twice. Find repeated fragments in the ciphertext, measure the distances between them, and those distances are almost always multiples of the key length. The key never shows itself, but its length does.

And the length is everything. Once you know the keyword has, say, five letters, split the ciphertext into five interleaved streams — every fifth letter belongs to the same key letter, which means each stream is an ordinary Caesar cipher. Al-Kindi's thousand-year-old frequency count finishes each stream in minutes. Many alphabets collapse back into one alphabet at a time.

Run the whole journey on your message

Part 7 — What it teaches

Ideas that outlived the ciphers

In 1883, with the Vigenère's fall still fresh, the Dutch cryptographer Auguste Kerckhoffs drew the conclusion that still governs the field: a cipher must remain secure even when the enemy knows everything about the system except the key. Caesar's cipher fails this test outright — the system is the secret, and there are only twenty-five keys once it leaks. Kerckhoffs's principle is why modern algorithms are published, standardized, and attacked in the open for years before anyone trusts them. Secrecy lives in the key alone.

And substitution itself never left. AES — the cipher protecting this page in transit — runs every byte through its S-box, which is literally a substitution table, 256 entries long. The differences are of scale, not kind: substitution on bits instead of letters, keys of 128 bits instead of a keyword, the operation repeated and interleaved with mixing over many rounds until no fingerprint of any sort survives. The Vigenère's move of using the key to vary the substitution is the same move, done thoroughly.

Part 8 — Further reading

Go deeper

David Kahn's The Codebreakers is the definitive history of the whole subject — al-Kindi, Bellaso, Babbage, and Kasiski all get their full stories, told with the archival receipts. It is a long book that earns its length.

Simon Singh's The Code Book covers the same arc in a single evening's read, with worked examples you can follow with a pencil — the Vigenère chapter walks a Kasiski break end to end and is the best next step after this page.

For the break itself, the Kasiski examination article lays out the repeated-fragment method with worked distances, close to how the lab's final stage presents it.

About this project

Hey—we're Sean and Derek.

Cryptography Explorer is meant to make the invisible visible: the encryption and hashing algorithms you trust every day, run live on your own input, slowed down far enough to actually understand.

It grew out of two terminal animations we used as teaching aids — Greg Walker's wonderful SHA-256 Animation (MIT licensed) and a companion RSA animation built in its spirit by AG1 Derek Conklin. The web gave us room those terminals never had: richer explanations at every step, a scrubbable timeline, and animations you can rewind.

Creators LT Sean Egan, PhD & AG1 Derek Conklin

United States Navy · A partnership building learning tools for our METOC, space, cyber, and cryptologic colleagues.

sean@theinformed.org

Independent educational project, built by us on our own time. The views expressed here are ours alone and do not reflect the official policy or position of the U.S. Navy, the Department of War / Department of Defense, or the U.S. Government, nor do we represent them. This site is intended for learning, not operations — do not use it for operational decisions; use it at your own risk. The classical ciphers on this page are broken by design of history: never use them to protect real secrets.