Leandro Junes

Vigenère Cipher

Encrypt text using a repeating keyword.

With A = 0, B = 1, …, Z = 25, and Ki the keyword letter that meets the i-th letter of the message,

Encryption Ci = Pi + Ki (mod 26)

Decryption Pi = Ci − Ki (mod 26)

Calculator

—
Mode

See the repeating key

—
Each column, top to bottom: plaintext letter, keyword letter, its shift, ciphertext letter

Current Caesar shift

—

How your message is transformed

—
Position Input Key Values Calculation (mod 26) Output

Position counts letters only; spaces, digits, and punctuation are not transformed, do not use a keyword letter, and are left out of the table.

Why does the keyword repeat?

A keyword of m letters supplies m Caesar shifts, one per letter. The message is usually longer than the keyword, so after the last key letter has been used the key starts again from the beginning. Spaces and punctuation that are preserved do not advance the keyword.

How is this related to the Caesar Cipher?

The Caesar Cipher uses one fixed shift for every letter, Ci = Pi + k. Vigenère uses a sequence of shifts, Ci = Pi + Ki: each keyword letter stands for one Caesar shift, and the strip above shows the one in force at the cursor. A one-letter keyword is exactly a Caesar cipher.

Why is Vigenère harder to attack with simple frequency analysis?

In the Caesar and affine ciphers one plaintext letter always becomes the same ciphertext letter, so the most common ciphertext letter gives the key away. In Vigenère the mapping depends on the position in the keyword, so the frequencies of the message are spread over several substitution alphabets and simple letter counting no longer works. The cipher is still not secure by modern standards: once the key length is known, each column is a Caesar cipher again, which is what Break mode exploits.

What is the Index of Coincidence?

It measures how often two letters picked at random from a text are the same: IC = Σ fi(fi − 1) / [N(N − 1)], where fi counts each letter and N is the number of letters. English-like text scores higher than uniformly random letters, because a few letters are very common. When a Vigenère ciphertext is split into columns using the correct key length, each column is Caesar-encrypted English and its IC tends to rise; with a wrong length the columns stay mixed and the IC stays low.

The Caesar Cipher is Vigenère with a one-letter keyword.

The Affine Cipher is monoalphabetic: for a fixed key, a plaintext letter always maps to the same ciphertext letter. Vigenère is polyalphabetic: the same plaintext letter can become different ciphertext letters, depending on its position under the repeating keyword.

Frequency Analysis

Index of Coincidence