What is the Vigenere cipher?
Let’s understand the Vigenere cipher with an example first. Let’s say the symbol size is 26 and we are encrypting English text. We are encrypting the plaintext “attackatdawn” with the key “road”.
Firstly, we would map each letter of the alphabet to an integer between 0 and 25. For example, ‘a’ will map to 0, ‘b’ will map to ‘1’, and so on.
Now, we would encrypt each letter of the plaintext using one letter of the key. But, the length of the plaintext is 12 and the length of the key is 4. So, we would need to repeat the letters of the key.
Plaintext: a t t a c k a t d a w n Keyword: r o a d r o a d r o a d
Now, we can map each letter of the key to an integer as discussed. And, we can then encrypt each letter of the plaintext with the corresponding integer using the Caesar cipher.
So, the ciphertext now becomes:
Plaintext: a t t a c k a t d a w n Keyword: r o a d r o a d r o a d Key(int): 17 14 0 3 17 14 0 3 17 14 0 3 Ciphertext: r h t d t y a w u o w q
In other words, if E and D are the encryption and decryption operations respectively, then:
Ci = E(Pi) = (Pi + Ki) mod symbol size Pi = D(Ci) = (Ci – Ki + 26) mod symbol size where Ci is the ith letter in the ciphertext, Pi is the ith letter of the plaintext and Ki is the ith letter of the extended key.
Vigenere cipher was first described in 1553 and it was considered indecipherable till 1863. In 1863, Friedrich Kasiski first published that successful attacks are possible on the Vigenere cipher.
How to implement the Vigenere cipher using Python?
The Vigenere cipher can be implemented using Python in the following way:
0 Comments