Vigenère cipher breaker

Finds the key length with the IC and Kasiski, solves every column as a Caesar shift by chi-squared, and gives the key and the plaintext.

How it works

The Vigenère cipher adds a repeating key to the plaintext: $y_i = (x_i + k_{i \bmod L}) \bmod 26$. It flattens the letter counts, which defeats plain frequency analysis, but it has a weakness: every $L$-th letter is enciphered with the same shift.

So the attack has two steps. First the key length $L$: the average index of coincidence of the $L$ columns becomes English-like at the right length, and Kasiski’s repeated sequences lie a multiple of $L$ apart. Then each column is a Caesar cipher on its own: try all 26 shifts and keep the one whose letter counts are closest to English by $\chi^2$.

Short columns can mislead $\chi^2$ by a letter or two, so the breaker finally polishes the key with quadgram fitness on the whole plaintext, one key letter at a time. Several key lengths are tried and the one whose plaintext reads best wins; you can also force the length. A few hundred letters are usually enough for keys up to 10 or so.

Everything is calculated in your browser. Nothing you type leaves your device.