# Program To Adjust Your Implementation of The Substitution in Python Assignment Solution.

## Instructions

Objective
Write a program to adjust your implementation of the substitution in python.

## Requirements and Specifications

Description of activity: In this exercise I would like you to adjust your implementation of the substitution (also known as mono-alphabetic) cipher.
Vigenere (also known as poly-alphabetic) cipher attempts to “smoothen out” the plaintext->ciphertext letter frequencies which occur in light of the one-to-one plaintext->ciphertext pairing embodied in the shift cipher.
Vigenere is explained in detail in the version 2 of the book on page 13. Your scheme should still implement all 3 algorithms namely key-generation, encryption, decryption. Ultimately you will use this programming exercise to play a mental game with yourself, where you play part of the sender (Alice), recipient (Bob) and malicious attacker (Eve). The outcome of this exercise is to see for yourself how the letter frequency cryptanalysis of the substitution cipher can be easily corrected via a poly-alphabetic method. Vigenere cipher is not a secure cipher, however in this exercise you do not need to worry and crypto analyse it, all you have to do is show me how the cryptanalysis of Substitution cipher is no longer possible here in the Vigenere cipher.
Source Code
```SUBSTITUTION CIPHER def key_map(plaintext_key, encrypted_key):     map = {}     for i in range(len(plaintext_key)):         map[plaintext_key[i]] = encrypted_key[i]     return map def encipher(plaintext_key, encrypted_key, text):     result = ''     map = key_map(plaintext_key, encrypted_key)     for c in text:         lc = c.lower()         if c in map:             result += map[lc]     return result def decipher(plaintext_key, encrypted_key, text):     result = ''     map = key_map(plaintext_key, encrypted_key)     for c in text:         lc = c.lower()         for cc in map:             if lc == map[cc]:                 result += cc                 break     return result if __name__ == '__main__':     plain_text = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',                  'u', 'v', 'w', 'x', 'y', 'z']     encrypted_text = ['b', 'e', 'c', 'd', 'f', 'g', 'h', 'z', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',                  'v', 'w', 'x', 'y', 'a', 'i']     text = 'Once upon a time'     print("Plain Text: ", text)     print("Encrypted Text: ", encipher(plain_text, encrypted_text, text))     encrypted = 'jsfbmmampwfcssaqup'     print("Plain Text: ", encrypted)     print("Encrypted Text: ", decipher(plain_text, encrypted_text, encrypted)) VIGENERE CIPHER def encipher(key, text):     result = ''     n = len(key)     i = 0     for c in text:         if not c.isalpha():             result += c         else:             lc = c.lower()             result += chr((ord(lc) + ord(key[i % n].lower()) - 2*ord('a')) % 26 + ord('a'))         i += 1     return result def decipher(key, text):     result = ''     n = len(key)     i = 0     for c in text:         if not c.isalpha():             result += c         else:             lc = c.lower()             result += chr((ord(lc) - ord(key[i % n].lower()) + 26) % 26 + ord('a'))         i += 1     return result if __name__ == '__main__':     key = 'cafe'     text = 'tellhimaboutme'     print("Plain Text: ", text)     print("Encrypted Text: ", encipher(key, text))     print()     encrypted = 'veqpjiredozxoe'     print("Plain Text: ", encrypted)     print("Encrypted Text: ", decipher(key, encrypted))```