Improve the Vigenere Cipher
Below is the code for the Vigenere Cipher's encryption algorithm. Improve it by supporting lowercase letters in the keyword and plaintext message. Assume that the keyword and plaintext will contain only letter characters. Follow the model of the simpler substitution ciphers to incorporate this change.
Examples:
vigenere_encrypt('Function','Joke') returns 'OixgcWYR'
vigenere_encrypt('HappyBirthday','presents') returns 'WrthcObjiyhscl'
def vigenere_encrypt(plaintext, keyword):
keyword = keyword * (len(plaintext) // len(keyword) + 1)
plaintext_nums = [ord(ch.upper()) - ord('A') for ch in plaintext]
keyword_nums = [ord(ch.upper()) - ord('A') for ch in keyword]
ciphertext = ''
for i in range(len(plaintext)):
ciphertext += chr((plaintext_nums[i] + keyword_nums[i]) % 26 + ord('A'))
return ciphertext
print(vigenere_encrypt('Function', 'Joke'))
print(vigenere_encrypt('HappyBirthday', 'presents'))
print(vigenere_encrypt('SpongeBobSquarePants', 'ImproveTheAlgorithm'))
OUJMICER
CDFTIOHPUKTEIR
ANJQALFTOCWRMRBDZGLG