How to use it
The lab has three parts. Encrypt & decrypt works while you type: choose a direction, type a keyword and type or paste a text. Only the letters A–Z change and their case is kept. Digits, spaces and punctuation are copied unchanged and do not use up a key letter. Letters with diacritics such as č, é or ô are first turned into plain letters; switch that off and they are copied unchanged, like punctuation.
Step by step shows the same text one letter at a time on the tabula recta. Crack it recovers an unknown key from the ciphertext alone: press “New mystery message” or bring your own ciphertext from the first tab.
Controls
- Keyword: any length; non-letters in it are ignored. “Random key as long as the text” uses the browser’s cryptographic random generator.
- Use the result as input swaps the boxes and the direction to check the round trip; the Copy buttons copy either box.
- Step by step: Next letter, back and Play. On the table, ← and → step, Space plays or pauses and Home starts again. Click a cell to look up any pair.
- Crack it: set the key length with − and + or a click on the IC chart. Select a key letter and change it with the buttons, the arrow keys or by typing; a click on the chi-squared chart picks a letter.
How it works
Number the letters A = 0 to Z = 25 and repeat the keyword under the letters of the text. With a key of length m:
With the key LEMON, ATTACK AT DAWN becomes LXFOPV EF RNHR. The tabula recta is the same sum as a table: the key letter picks the row, the plaintext letter the column, and the cell holds the ciphertext letter. One plaintext letter turns into several different ciphertext letters, so letter counts look flat. The weakness is that the key repeats.
Kasiski examination. The same piece of plaintext under the same part of the key gives the same ciphertext. The lab lists the three-letter sequences that occur more than once and the distances between them; the key length divides most of these distances. Small numbers such as 2 and 3 always score well, so look for the largest well-supported factor.
Index of coincidence. The IC is the chance that two letters picked from the text are the same, where ni counts each letter and N is the number of letters:
English prose gives about 0.066, random letters 1/26 ≈ 0.0385. For each length from 1 to 20 the lab splits the ciphertext into columns (every m-th letter) and averages their IC; at the right length every column keeps the English value. The suggestion is the smallest length that reaches 92 % of the best average, counting only lengths with at least 15 letters per column. William Friedman’s rough estimate uses the whole text: m ≈ (0.066 − 0.0385) / (IC − 0.0385).
Frequency analysis. Each column is now a simple shift cipher, the one you can crack in the Caesar Cipher lab. For each possible key letter the lab decrypts the column and compares its letter counts O with the counts E expected in English, χ² = Σ (O − E)² / E. The lowest score wins. The English frequencies are the widely used table published by Robert Lewand in Cryptological Mathematics (2000).
Things to try
- Encrypt the lighthouse sample with a short key and compare the frequency charts: the peaks of English flatten out.
- Crack a few mystery messages: the IC bars at the key length and its multiples rise to about 0.066.
- Cut a mystery ciphertext down to about 100 letters. Some key letters often come out wrong; fix them by hand until the text reads well.
- Set the key length to twice the real one: the key spells the word twice and the lab tells you it repeats.
- Make a random key as long as the text and crack the result: every IC bar stays near 0.038.
Frequently asked questions
Who invented the Vigenère cipher?
Giovan Battista Bellaso described it in 1553. It was later credited to Blaise de Vigenère, who published a stronger autokey cipher in 1586. The square table goes back to Johannes Trithemius in the early 1500s. For about three centuries the cipher was widely thought to be unbreakable.
Who broke it?
Charles Babbage is known to have broken it in the 1850s, but he never published his method. Friedrich Kasiski published the repeat method in 1863, and William Friedman introduced the index of coincidence in the 1920s.
Can it be made unbreakable?
Yes, with a truly random key that is at least as long as the message and used only once. Then nothing repeats and every plaintext of that length is equally likely: the cipher becomes a one-time pad, the same idea as the Vernam cipher, which Claude Shannon proved unbreakable in the 1940s. The random key here comes from a cryptographically secure generator, not from a physical random source.
Why does the crack fail on short texts?
A 120-letter text with a 7-letter key leaves about 17 letters per column, too few for reliable counts. The lab warns when columns hold fewer than 40 letters.
Sources
- Friedman WF (1922, revised later). The index of coincidence and its applications in cryptanalysis. War Department technical paper, a revision of the Riverbank paper of 1922, scanned from the Friedman collection released by the NSA. The coincidence rates of about 0.066 for English and 0.038 for random letters.
- Lewand RE (2000). Cryptological Mathematics. Mathematical Association of America. The English letter frequency table used for the chi-squared step.