Vigenère Cipher

Definition, how it works, and an interactive tool.

• Read time: ~7 min

What is the Vigenère cipher?

The Vigenère cipher is a polyalphabetic substitution method. Instead of using a single shift (as in Caesar), it applies a sequence of shifts defined by a repeated keyword across the message. Each letter is encrypted using a different “alphabet,” making frequency analysis far more difficult.

For every position, the letter from the plaintext (A–Z) is combined with the corresponding letter from the key (A–Z). The shift value is the alphabetical index of the key letter (A=0, B=1, …, Z=25). The key is repeated or truncated to match the length of the message.

How it works

Normalize the text (for compatibility with a 26-letter alphabet: accents → base form) and decide how to treat ñ/Ñ — you can either preserve it without encryption or map it to N, but the choice must be documented for consistency. Then repeat the key until it covers the entire message.

Formulas

Encryption:   Cᵢ = (Pᵢ + Kᵢ) mod 26
Decryption:   Pᵢ = (Cᵢ - Kᵢ + 26) mod 26

where:
  Pᵢ = index (0–25) of the i-th plaintext letter
  Kᵢ = index (0–25) of the i-th letter of the repeated key
  Cᵢ = index (0–25) of the i-th ciphertext letter
  

Notice that Vigenère operates linearly over ℤ26: its strength depends entirely on the length and randomness of the key.

Example

Quick example

Plaintext: ATAQUEAMANECERKey: CLAVE
Repeated key: CLAVECLAVECLAV

First letter: A with C (2) → C. Second letter: T with L (11) → E. Continue adding the key’s shift (mod 26) for each position.

Tip: if you keep spaces or punctuation, indicate it in the tool; otherwise, they are usually removed before encryption. Accents are normalized (á→a), and ñ/Ñ can be preserved for didactic purposes.

History

  • Polyalphabetic ideas described by Leon Battista Alberti (15th century).
  • Developed by Giovan Battista Bellaso (1553) with explicit use of a key.
  • Commonly attributed to Blaise de Vigenère (1586), hence the name.
  • Considered "undecipherable" for centuries until 19th‑century techniques.

Classic attacks

  • Kasiski examination: identifies repeated sequences to estimate the key length.
  • Index of coincidence (Friedman test): statistically estimates the key length.
  • Column separation: once the key length is known, divide the ciphertext into groups and apply Caesar analysis to each column.

Short or reused keys make Vigenère vulnerable; the longer and more random the key, the stronger the resistance against these methods.

Pros and cons

Pros

  • Much stronger than Caesar against basic frequency analysis (if the key is long enough).
  • Excellent for teaching polyalphabetic substitution and key-based encryption.
  • Simple to implement and visualize in interactive learning tools.

Cons

  • Insecure with short or reused keys (broken by Kasiski/Friedman with enough ciphertext).
  • Provides no integrity or authenticity — only basic confidentiality.
  • Not suitable for real-world data protection in modern contexts.

Vigenère Encryption & Decryption Tool

The key may contain only letters A–Z (diacritics and symbols are ignored).