✖

Vigenère cipher

The Vigenère cipher is a famous cipher that uses several cipher alphabets, which makes it far more resistant to classical frequency analysis.

How encryption and decryption work

We can explain the procedure using the Caesar cipher. The key of the Vigenère cipher is any word made up of letters of the English alphabet, that is, a—z. For example, the key can be the word “bcf”. Encryption then works like this: we write out the plaintext and directly below it the key, which we repeat until it is as long as the plaintext. For the plaintext “goodevening” it would look like this:

Plaintext:goodevening
Key:bcfbcfbcfbc

Now we would encrypt all the letters of the plaintext using the Caesar cipher with the corresponding key, that is, the key in the same column. The Caesar cipher is a shift cipher: the key says by how many letters we shift the plaintext letter, measured from the letter “a”. For example, the letter “b” means a shift by one letter “to the right” in the alphabet. The letter “d” means a shift by three letters to the right. Using the Caesar cipher with the key “b”, we would encrypt the word “hello” as “ifmmp”.

Whereas in the Caesar cipher we encrypt the whole text with a single letter, in the Vigenère cipher we typically encrypt with several letters. Encrypting the text “goodevening” with the key “bcf” would therefore turn out like this:

Plaintext:goodevening
Key:bcfbcfbcfbc
Ciphertext:hqtegafpnoi

We encrypted the first letter “g” with the key “b”, which is a shift by one letter, so the result is the letter “h”. We encrypted the letter “o” with the key “c”, which is a shift by two letters, so the result is the letter “q”. And so on.

We decrypt in exactly the same way, except that instead of shifting the letters “to the right”, we shift them “to the left”.

Online tool for encrypting and decrypting the Vigenère cipher

Text:
Key:

The Vigenère square

The whole procedure of encryption and decryption can also be explained using the Vigenère square, an aid that we can use while encrypting. The Vigenère square is a table with 26 rows and 26 columns. Each row contains the alphabet, shifted by one letter relative to the row before it:

With such a Vigenère square, encryption would go as follows: we take a letter of the plaintext and find the row with that letter. Then we take the letter of the key and find the column. The letter of the ciphertext is then the letter at the intersection of that row and column.

In the previous example we encrypted “goodevening” with the key “bcf”. So we find the row that begins with “g” and the column that begins with “b”. At the intersection of this row and column is the letter “h”, the resulting letter of the ciphertext.

When decrypting, we would proceed the other way round. If we wanted to decrypt the letter “h” using the key “b”, we would find the column “b”, find the row in it that contains the letter “h”, and the letter at the beginning of that row would be the letter of the plaintext.

The main strength of the Vigenère cipher

Why was the Vigenère cipher so strong in its day? Because it made classical frequency analysis considerably harder. For example, in the Caesar cipher, two identical letters of the plaintext are encrypted as the same letter in the ciphertext. This is not the case in the Vigenère cipher, at least not always.

If we encrypted the text “great great great” with the key “stan”, we would get the ciphertext “ykenl zrrsm gewtt”. We can see that although the plaintext contains three identical words, in the resulting ciphertext each word looks completely different. The middle word, “zrrsm”, even contains the letter “r” twice, yet the two came from two different letters of the plaintext: “re”.

Choosing the key

The security of the Vigenère cipher is greatly affected by the choice of key. Whereas with the Caesar cipher it did not matter which letter we chose, as long as it was not “a”, with the Vigenère cipher different keys give very different levels of security.

  • A key consisting of only one letter reduces the Vigenère cipher back to the Caesar cipher.
  • A key consisting of several identical letters, for example “mmm”, again leads to the Caesar cipher.
  • Text encrypted with a short key will be very easy to crack.
  • A sufficiently long ciphertext that was encrypted with a key that is not very short (around fifty characters) will also be very easy to crack. On a computer, within seconds.
  • Text encrypted with a key that is completely random and as long as the text itself will be impossible to crack.