## CS8 Programming Assignment 3## DescriptionIn this programming assignment, you will implement the Vigenère encryption algorithm (cipher). Refer to the Wikipedia page about the algorithmic details of the Vigenère cipher. You should pay special attention to:- Section "Description" for a real example;
- Section "Algebraic description" for mathematical illustration
In our project, we will use the lower case letters alphabet = "abcdefghijklmnopqrstuvwxyz0123456789 .,?!"which has 26+10+5=41 elements, and thus, we will use mod 41 arithmetic. Therefore the lower case letter ( "a" to "z") indices
are 0 to 25, the number ("0" to "9") indices are 26
to 35, and the indices for the space, dot, comma, question mark,
exclamation mark characters are respectively
36, 37, 38, 39, and 40.
## RequirementsYou need to write two functions, as described below. Function names and parameter properties must be as specified.- The encryption function definition is
def encVigenere(key, plaintext) Both key and plaintext are string arguments, such asencVigenere("my key for today","attack at dawn!") The function accepts an plaintext message of any length (a string of at least 1 character) and encrypts it using the key of any length (which is another string of at least 1 character), and**returns**the encrypted text (called ciphertext). The length of the ciphertext and plaintext will be the same. The key length may be shorter or longer than the plaintext. - Similarly, the decryption function definition is
def decVigenere(key, ciphertext) Both key and ciphertext are string arguments. The function accepts the ciphertext as input, and decrypts it using the key, obtains back the original message (the plaintext) and**returns**it.
## An Encryption ExampleKey:lemonade Plaintext: meet me at caje at 2pm! According to the variable alphabet (above), the indices of the (repeated) key and text letters are: Key : l e m o n a d e l e m o n a d e l e m o n a d Key : 11 04 12 14 13 00 03 04 11 04 12 14 13 00 03 04 11 04 12 14 13 00 03 Text: m e e t m e a t c a j e a t 2 p m ! Text: 12 04 04 19 36 12 04 36 00 19 36 02 00 09 04 36 00 19 36 28 15 12 40The encrypted text is obtained using mod 41 addition as Key : 11 04 12 14 13 00 03 04 11 04 12 14 13 00 03 04 11 04 12 14 13 00 03 Text: 12 04 04 19 36 12 04 36 00 19 36 02 00 09 04 36 00 19 36 28 15 12 40 -------------------------------------------------------------------------- Ciph: 23 08 16 33 08 12 07 40 11 23 07 16 13 09 07 40 11 23 07 01 28 12 02 Ciph: x i q 7 i m h ! l x h q n j h ! l x h b 2 m cTherefore, the resulting ciphertext is xiq7imh!lxhqnjh!lxhb2mc
## What To SubmitWrite both of your functionsencVigenere and decVigenere
in a Python text file named pa3.py, and submit your file using the
Dropbox link. Your functions will be tested using random values of
key, plaintext, and ciphertext.
Submit only the functions; no test programs outside the functions are
needed. Also, you may write and include in your
This programming assignment is graded out of 15 points, i.e., it has
cs8 web page |