Question: in python pls Description: Today we will implement a simple encryption algorithm. Consider the following scenario: Alice wants to send a message to Bob, but



Description: Today we will implement a simple encryption algorithm. Consider the following scenario: Alice wants to send a message to Bob, but is worried that Eve is eavesdropping and will be able to read the message. So Alice encrypts the message: Alice takes the original message M, called the plaintext, and applies an encryption algorithm E to produce the ciphertext C. The ciphertext C looks like gibberish, and Eve cannot read it if she intercepts it. When Bob receives C, he applies the decryption aigorithm to recover the original plaintext The Decryption and Encryption Algorithms (Step 1) Alice first writes the plaintext message simply as a sequence of letters, removing all spaces and punctuation and capitalization So if the message is We're having a surprise birthday party Alice will first transform it into werehavingasurprisebirthdayparty (Step 2) Alice then chooses an integer value (lets say between 2 and 100) which will be used to rotate the values. (Step 3) For each character/letter in the message, Alice will shift the letter by the value given by the int decided on in Step 2. For example: - If the letter is ' a ' and the int is 2 , then the letter is shifted forward twice to become ' c '. - If the letter is ' 2 ' and the int is 2 , then the letter is shifted forward twice to become ' b ' (circles back to the beginning). - if the letter is ' g ' and the int is 4 , then the letter is shifted forward twice to become ' k. (Step 4) Alice sends the message to Bob. Note, even if Eve intercepts the message, we cannot read it easily. (Step 5) Bob applies the decryption algorithm which basically shifts each letter / character backwards by the int given in Step 2. You will need to begin by implementing certain functions that perform the encryption and decryption. The core of it all is the basic shift. function, which I will give you here: def shift (ch,k) : return chr (ord (a)+(ord(ch)-ord (aa)+k)126) Here ch is a character and k is an integer, the shift amount, so that shift (w,5) will return b ', and shift(b',-5) will return ' w '. Weil talk in class about what all the ord and chr stuff is, since you'l need to use it in the rest. We have also provided you with the following pre.process function that gets rid of all spaces and puncuation and converts all characters to lowercase. pre process ("We' re having a surprise birthday party for Eve next saturday night,") returns the string 'werehavingasurprisebirthdaypartyforevenextsaturdaynight' Finally, put the pieces together to write the encryption and decryption algorithms encrypt (plaintext, k) decrypt (ciphertext, k ) For instance enerypt ("We're having a surprise birthday party for Eve next Saturday night," , 3) returns the string ' xf sf ibwjohbtvsqsjtfcjsuiebzqbsuzgps fwfofyutbuvsebzojhiu' and decrypt ('xfof ibwjohbvsqsjt fojsuiebzqbsuzgpsi wEofyutbuvsebzojhiu', 3) main.py Load default template... Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. 'werehavingasurprisebirthdaypartyforevenextsaturdaynight' \begin{tabular}{l|l} UAB \\ Nctiviry & 16.1.1: LAB: Encryption / Decryption-Part 1 (Cesar cipher) \end{tabular} main.py Load defoult template. Run your program as often as you'd like, before submitting for grading Betow, type any needed input values in the first box, then click Run program and observe the programs output in the second bax
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
