From 62bbbee41b273c9e01707803f66654ffc73fffb2 Mon Sep 17 00:00:00 2001 From: Sanket Baraiya <56958135+SanketBaraiya@users.noreply.github.com> Date: Sat, 30 Oct 2021 15:11:32 +0530 Subject: [PATCH] Create Vigenere Cipher.py Vigenere Cipher Using Python --- Python/Vigenere Cipher.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Python/Vigenere Cipher.py diff --git a/Python/Vigenere Cipher.py b/Python/Vigenere Cipher.py new file mode 100644 index 0000000..c6b7d29 --- /dev/null +++ b/Python/Vigenere Cipher.py @@ -0,0 +1,38 @@ +matrix = [] +for i in range(26): + temp = [] + for j in range(26): + tempVal = i+j+65 + if tempVal <= 90: + temp.append(chr(tempVal)) + else: + tempVal = (tempVal % 65) + 39 + temp.append(chr(tempVal)) + matrix.append(temp) +print("================") +print("Vigenere Table") +print("================") +for rows in matrix: + print(rows) + +cipherText = '' +auto = False +plainText = list( + (input("\nEnter Your Plain Text :: ").upper()).replace(" ", "")) +key = list((input("Enter Your Key :: ").upper()).replace(" ", "")) + +c = 0 +while len(key) != len(plainText): + auto = True + key.append(plainText[c]) + c += 1 +if auto == True: + + print("Auto Key Generated: ", end="") + print(''.join(map(str, key))) + +for i in range(len(plainText)): + pNo, kNo = ord(plainText[i])-65, ord(key[i])-65 + cipherText += matrix[kNo][pNo] + +print("\nCipher Text:", cipherText)