# Vigenère cipher

The Vigenère cipher is a more complex substitution cipher. Watch the encryption and decryption process, as well as how it can be broken
2.6
Vigenére cipher involves using multiple Caesar ciphers to encrypt a message, making it much harder to crack. To encrypt your message, you need a key of random letters. The longer the key, the harder it is to break the encryption. You also need a Vigenére square, which you can make using a 26 by 26 cell grid or spreadsheet. Write the alphabet in the first row and column like this. Then fill each column starting with the letter in the top cell. When you read zed, begin the alphabet again. You will end up with something that looks like this. To encrypt your message, you substitute each letter with another, using your key to find the intersection of the correct row and column.
41.7
For example, if it messages HELLO, you encrypt the first letter H using row H. Then you use the first letter of your key to choose the correct column. Your key here is RPI. So you need to find the intersection of row H with column R, which gives you the letter Y. You then repeat this for the second letters of the message and of the key, the third letters, and so on. If your message is longer than your key, you loop through the letters of the key in order until your entire message is encrypted. So here, HELLO becomes YTTCD. To decrypt a Vigenére ciphertext, you reverse the process. First, find the row that corresponds to the first letter in the key.
81.1
And in that row, find the first letter in the ciphertext. The letter at the top of this column is your first plaintext letter. Then repeat the process for each letter in the ciphertext. Previously, you broke the Caesar cipher by looking for patterns in the text that were preserved by the encryption scheme. The Vigenére cipher isn’t so easy to break, because the substitution is different for each letter. That means it’s harder to spot patterns or frequently used letters. However, it’s not unbreakable. In the Second World War, British spies used the lines of famous poems as their keys. When German code breakers figured this out, it became easy to guess the keys and decrypt the messages.
118.3
Patterns in a ciphertext can still provide clues for figuring out the key. A repeated sequence of letters is more likely to be the same part of a word that was encrypted using the same part of the key, rather than two different sets of letters encrypted to produce the same sequence. Dragging is another technique used to crack the cipher. By guessing a word from the message, you can check whether it’s been encrypted at every possible position until you find a likely key. For example, imagine you intercept a message from Alanis Morissette. And you suspect that she’s been talking about the weather. You could check whether the word “rain” has been encrypted until you can guess part of the key.
155.4
Once you have a clue to the key, you can try to decrypt the rest of the message. If you haven’t found the whole key, you might need to try multiple approaches until you can spot patterns in the message. This method of decryption requires more deduction and guesswork than the Caesar cipher. Now you have a go at decrypting this ciphertext using the key polyalphabetic. Then share your answer to the decrypted question in the comment section.
183.2
[CLICK]

You might remember the Vigenère cipher from the earlier step about the history of encryption. It is a polyalphabetic cipher that uses multiple shifts to encrypt a message. In this step, you are going to look at how the extra complexity in the Vigenère cipher helped make it a much more robust encryption scheme than the Caesar cipher.

### The encryption process

To encrypt a message, you need to choose a key and use a Vigenère square.

The key is a string of letters. A Vigenère square is a grid formed by repeatedly writing the alphabet, starting at different places.

To encrypt a message, you will replace each letter in the message with another letter, chosen by finding the intersection of the correct row and column. To choose the row, find the letter of your message in the first column. If your message was “hello”, the first letter would be encrypted using the row beginning with the letter ‘h’.

To choose the correct column, you need your key. For the first letter in your message, choose the column that starts with the first letter in the key; for the second letter in your message, choose the column that starts with the second letter of your key, and so on. For instance, if your key was “RPI”, the first letter in the message would be encrypted using the column beginning with the letter ‘R’, the second letter would be encrypted using the column beginning with the letter ‘P’, and the third using the column beginning with the letter ‘I’. If the message is longer than your key, simply reuse the letters in your key in order.

Using this process, the letter ‘h’ is encrypted as ‘y’, and the letter ‘e’ is encrypted as ‘t’. The first ‘l’ also becomes ‘t’, but the second ‘l’ becomes ‘c’. Finally, the letter ‘o’ becomes ‘d’. This encrypts the word “hello” as “yttcd”.

To test your understanding of the method, encrypt the following message:

I am encrypting a message

To decrypt a message, you reverse the process by first finding the row that corresponds to the current letter in the key, then looking along that row until you find the corresponding letter in the ciphertext. The letter at the top of this column is the plaintext letter.

To decrypt the ciphertext “yttcd”, start at column ‘R’ and find the position of the letter ‘y’ in this column. At the start of this row is the letter ‘h’ — the first letter of the plaintext. Just like in the encryption process, when you get to the end of the key, you wrap around and use the first letter again.

### Measuring the complexity of the Vigenère cipher

This encryption method is certainly more complex than the Caesar cipher that you looked at earlier. To assess how secure the Vigenère cipher is, consider the key areas that you were introduced to in the previous step.

Key length

The key in a Vigenère cipher can vary in length from two characters to the length of the plaintext. The longer the key is and the more random it is, the harder the scheme is to crack. With short keys, you are likely to encrypt similar words or parts of words in the plaintext with the same part of the key, giving an attacker some clues as to what the key might be.

Algorithmic complexity

The encryption and decryption algorithms require multiple steps for each character. These extra steps mean that it will take an attacker longer to test their guesses at the key. For each character in the plaintext, there are many more permutations to try, adding more steps and more complexity.

Methods of attack

In this area, the Vigenère cipher really shines. You saw in an earlier step that monoalphabetic substitution ciphers are vulnerable to frequency and pattern analysis, because they preserve patterns in the plaintext. Polyalphabetic ciphers do not suffer from the same weaknesses. The number of places that a letter is shifted in the alphabet can change for each letter in the message, which means that the most frequently used letter in the ciphertext does not correspond to the most frequently used letter in the plaintext.

It is not unbreakable, however, and there are still some patterns that can give an attacker clues as to what your key is. If the same pattern appears in the ciphertext multiple times, it can indicate the same word being encrypted with the same part of the key.

I would like you to practise using the Vigenère cipher to decrypt a message.

The following ciphertext has been encrypted with the key “polyalphabetic”:

“Lvlr yppy wbw mpg Kwrcnpgl cjtamt uwyylwn jrbgdmf, tbognr xa’s sibop pg efe fcirfedidas ngpsty?”

Post only your answer to the question that the message poses in the comments section below, so that you don’t give the plaintext away to other learners.