Vigenere Cipher Report
Vigenere Cipher Report
'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] (*)
import random
This is a library function for generating random numbers
def Key_Generation(size):
We have defined the function for generating the key ????
key = ''
We have defined an empty key
temp_copy = Alphabet.copy()
????
for i in range(26):
This for loop is to.???????
key = key +
temp_copy.pop(random.randint(0,len(temp_copy)-1))
?
if i == (size-1):
This statement will check
break
This statement will stop the for loop once..
return key
The function returns the ciphertext when plaintext..?
if char in Alphabet:
This statement will check whether the character of the plain
text is in the set of the defined alphabet (*)
ciphertext = ciphertext +
Alphabet[(Alphabet.index(char) + Alphabet.index(key[counter]))
% 26]
If the character of the plain text is in alphabet then we
encrypted it by shifting with the value of key
counter = counter + 1
??
if counter == size:
This statement will check whether te size
counter = 0
If the counter 0 then we..??
else:
If the character of the plain text is not in alphabet (*) then we
do the following
ciphertext = ciphertext + char
We make the character part of the character without encrypting
return ciphertext
The function returns the ciphertext when plaintext is encryipted
completely
counter = 0
???
size = len(key)
??
print('key:: ', key)
We are printing the key to make sure that it matches
encryption key
for char in ciphertext:
This for loop will read each character of the cipher text
if char in Alphabet:
This statement will check whether the cipher text character is in
alphabet if so then we do the following
plaintext = plaintext + Alphabet[(Alphabet.index(char) Alphabet.index(key[counter]))% 26]
We decript the cipher text character by
counter = counter + 1
?
if counter == size:
?
counter = 0
?
else:
If the character is not in the alphabet then we do the following
plaintext = plaintext + char
return plaintext
Once a ciphertext is decrypted completely than we returned the
plain text