Kasiski Test for Vigenère
Find repeated trigrams in ciphertext, compute GCD of distances and suggest the Vigenère key length.
—
Kasiski: finding the key length by counting distances
Vigenère held out for three centuries for a simple reason: with the key changing the alphabet on every letter, frequency analysis finds nothing. Friedrich Kasiski published in 1863 the observation that brought it down. If a stretch of plaintext repeats and lands aligned with the same part of the key, it produces the same ciphertext stretch — and the distance between the two occurrences is a multiple of the key length.
Paste the ciphertext and the page looks for repeated trigrams, lists the distances between their occurrences and computes the greatest common divisor. That divisor is the best estimate of the key length. With the length in hand the cipher falls apart: separating the letters into positions spaced by that length, each group was enciphered with a single alphabet, and each group yields to ordinary frequency analysis.
The method needs text to work — a few hundred characters at least, because trigram repetitions are rare in little material. It also produces false positives: trigrams repeating by chance, with no key alignment, contaminate the divisor. So it pays to look at the distances one by one rather than accepting the divisor blindly, discarding the ones that stand out.
Frequently asked questions
Why trigrams and not letter pairs?
Is there another way to find the key length?
Does it work on Vigenère with a key as long as the text?
Related Tools
Index of Coincidence Calculator
Compute Index of Coincidence (IC) of ciphertext to distinguish mono/polyalphabetic ciphers — classic cryptanalysis tool.
Vigenère Cipher
Encrypt and decrypt text with the polyalphabetic Vigenère cipher using a keyword. More robust than Caesar by using multiple shifts. Everything in your browser.
Frequency Analysis to Break Ciphers
Count letter, bigram and trigram frequencies in ciphertext and compare with Portuguese/English references.
Vigenère Autokey Cipher Encoder and Decoder
Enciphers or deciphers text with the classic autokey variant, where the plaintext extends the keyword instead of repeating it. Letters A to Z only.
Password Strength Checker
Analyze the strength of any password: length, character classes, entropy in bits and resistance estimate. Processed in the browser — the password never leaves your device.
HIBP K-Anonymity Format
Explains the Have I Been Pwned k-anonymity flow: SHA-1 password, first 5 chars on GET, suffix returned.