Skip to content
CryptographyInternals

Vigenère cipher

A repeating keyword picks a different Caesar shift for each letter.

Family
Polyalphabetic substitution
Era
1553 (Bellaso), named after Vigenère
Keys
26ⁿ for a key of n letters

Giovan Battista Bellaso described this cipher in 1553; it was later credited to Blaise de Vigenère. For three centuries it was called le chiffre indéchiffrable, the indecipherable cipher.

Each letter of the keyword gives a Caesar shift (A = 0, B = 1 … Z = 25). The keyword repeats along the message, so the same plaintext letter can encrypt to different ciphertext letters.

Message
A
T
T
A
C
K
A
T
D
A
W
N
L
E
M
O
N
L
E
M
O
N
L
E

01 / 12 · Inside the Vigenère cipher

A message to hide

This readable text is the plaintext. Encrypting turns it into ciphertext. Classical ciphers only touch letters.

The goal: whoever intercepts the ciphertext must not get back to these letters.

Playground

Encrypt with your own keyword

Type a message and a keyword, then step through: each letter is shifted by the key letter under it. The panel on the right does the sum for each of your letters.

Your input

Only the letters A–Z count.

Result
LEMON
Input
Key
Output

Encrypt

5 Caesar shifts taking turns

What happens

Each keyword letter stands for a shift: A = 0, B = 1 … Z = 25. The keyword is written again and again under the message, and each letter is shifted by the key letter below it.

On your values

L=11 E=4 M=12 O=14 N=13

C = (P + K) mod 26

Why it matters

Changing the shift from letter to letter hides which plain letters are common. But the keyword repeats every 5 letters: that period is the crack Kasiski published in 1863 (see below).

Spaces, digits and punctuation pass through unchanged; accents are dropped.

The basics: Modular arithmetic →

Start

How it’s broken

Find the key length, then solve one Caesar cipher per column

Words that repeat in the message sometimes meet the same key letters, so the same cipher fragment appears twice. The distance between the two copies is a multiple of the key length (Friedrich Kasiski, 1863). Once the length is known, every column of letters is a plain Caesar cipher, broken by letter frequencies.

Repeated fragments and their distance

No fragment of 3 or more letters repeats in this ciphertext: the method needs a longer text. Try the long-text preset.

How many distances each key length divides

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
your ciphertextEnglish letters

The ciphertext’s letter counts are flatter than the language’s: no bar stands out the way E does, so a single frequency count fails.

Column j holds letters j, j + 5, j + 10…; each one was shifted by a single key letter. The best Caesar shift of each column:

  1. j=0H = 7
  2. j=1E = 4
  3. j=2B = 1
  4. j=3K = 10
  5. j=4W = 22
Recovered key

Decrypted with it

Eteeto ae hran

Short texts can fool the statistics: the longer the ciphertext, the surer the attack. Try the long-text preset.

How it works

  1. 1Write the keyword repeatedly under the plaintext letters, skipping spaces and punctuation.
  2. 2In the tabula recta, go to the row of the key letter and the column of the plaintext letter.
  3. 3The letter where they cross is the ciphertext letter.
  4. 4To decrypt, find the ciphertext letter in the key letter's row; its column heading is the plaintext letter.

Formula

Cᵢ = (Pᵢ + Kᵢ mod n) mod 26
Pᵢ = (Cᵢ − Kᵢ mod n) mod 26

How it is broken

The key repeats. Charles Babbage and later Friedrich Kasiski (1863) found that repeated fragments in the ciphertext reveal the key length.

Once the key length n is known, every n-th letter was encrypted with the same Caesar shift, and each of those groups falls to frequency analysis.

Read the in-depth articleHow to Crack a Caesar Cipher and Break VigenèreA hands-on cryptanalysis tutorial: crack a Caesar cipher by brute force and frequency analysis, then break Vigenère with Kasiski to recover the key LEMON.