Skip to content
Toolcroft

Password & Security

Vigenère Cipher - Encode & Decode Online

Encode or decode text with the Vigenère cipher. Enter your text and a keyword - each letter is shifted by the corresponding letter of the repeating keyword.

Ciphertext

What is the Vigenère cipher?

The Vigenère cipher is a classical polyalphabetic substitution cipher invented in the 16th century. Unlike the Caesar cipher which uses a single fixed shift, Vigenère uses a keyword: each letter of the keyword determines the shift for the corresponding letter of the message. The keyword repeats as needed. For example, with keyword LEMON and message ATTACKATDAWN, the shifts are L(11), E(4), M(12), O(14), N(13), L(11), E(4), M(12), O(14), N(13), L(11), repeated, producing LXFOPVEFRNHR.

How encoding works

For each alphabetic character at position i, find the key character k = keyword[i mod key-length]. The encoded character is (plaintext + k) mod 26. Decoding reverses this: (ciphertext − k + 26) mod 26. Non-alphabetic characters (spaces, digits, punctuation) are passed through unchanged, and the key index only advances on alphabetic characters.

Is the Vigenère cipher secure?

No, not by modern standards. The Vigenère cipher was considered unbreakable for centuries until Charles Babbage and Friedrich Kasiski independently showed that repeated keyword patterns leave statistical fingerprints. The Kasiski test and index-of-coincidence analysis can break it given sufficient ciphertext. Use it for puzzles, educational purposes, and historical study. Not for protecting real secrets.

Kasiski examination

The Kasiski test exploits the fact that when a keyword repeats, the same plaintext letters encrypted with the same key positions will produce repeated ciphertext substrings. By finding repeated substrings in the ciphertext and measuring the distances between them, an analyst can deduce the key length (it will divide most of the distances). Once the key length L is known, every Lth character was encrypted with the same Caesar shift, and each of the L groups can be broken by frequency analysis independently.

Index of coincidence

Friedman’s index of coincidence (IC) is the probability that two randomly selected characters from a text are the same. English plaintext has IC ≈ 0.065; uniformly random text has IC ≈ 0.038. A Vigenère ciphertext with a short key has an IC closer to English (0.065) than to random, while a long key pushes it toward 0.038. By testing different assumed key lengths and measuring the IC of each subgroup, analysts can identify the true key length statistically.

Historical context

The Vigenère cipher was described by Giovan Battista Bellaso in 1553 but was misattributed to Blaise de Vigenère in the 19th century (who had described a different, stronger autokey cipher). For nearly 300 years it was known as le chiffre indéchiffrable - the unbreakable cipher. Charles Babbage cracked it around 1854 but kept his method secret for strategic reasons; Friedrich Kasiski independently published the attack in 1863.