Vigenère Cipher
Vigenere Cipher is a method of encrypting alphabetic text.
It uses a simple form of polyalphabetic substitution.
A polyalphabetic cipher is any cipher based on substitution, using
multiple substitution alphabets.
The encryption of the original text is done using the Vigenère square or
Vigenère table.
The table consists of the alphabets written out 26 times in different
rows, each alphabet shifted cyclically to the left compared to the
previous alphabet, corresponding to the 26 possible Caesar Ciphers.
At different points in the encryption process, the cipher uses a different
alphabet from one of the rows.
The alphabet used at each point depends on a repeating keyword.
Example:
Input:
Plaintext: GEEKSFORGEEKS
Keyword: AYUSH
Output:
Ciphertext: GCYCZFMLYLEIM
For generating key, the given keyword is repeated in a circular manner
until it matches the length of the plain text.
The keyword "AYUSH" generates the key "AYUSHAYUSHAYU"
The plain text is then encrypted.
Encryption:
The first letter of the plaintext, G is paired with A, the first letter of the
key. So, use row G and column A of the Vigenère square, namely G.
Similarly, for the second letter of the plaintext, the second letter of the
key is used, the letter at row E and column Y is C.
The rest of the plaintext is enciphered in a similar fashion.
Vigenère square / table to encrypt – Geeks
Row (plain text) Column (key) Cipher
G a G
E y C
E u Y
K s C
S h Z
Decryption:
Decryption is performed by going to the row in the table corresponding
to the key, finding the position of the ciphertext letter in this row, and
then using the column’s label as the plaintext.
For example, in row A (from AYUSH), the ciphertext G appears in column
G, which is the first plaintext letter.
Next, we go to row Y (from AYUSH), locate the ciphertext C which is
found in column E. Thus, E is the second plaintext letter.
The rest of the ciphertext is deciphered in a similar fashion.
Row (key) Cipher text Plain text
(find cipher letter in the corresponding row) (column label)
a g G
y c E
u y E
s c K
h z S