Question: BlockPy: 4 ) encrypt _ text / decrypt _ text The encrypt _ text function should consume the plaintext message ( a string ) and

BlockPy: 4) encrypt_text/decrypt_text
The encrypt_text function should consume the plaintext message (a string) and rotation_amount (an integer) and produces a string where the text is encrypted as follows:
Convert the string to a list of integers using ord.
Rotate each integer of the string by rotation_amount amount. To rotate a value, use the following formula: rotated =(original+rotation-32)%94+32. Hint: use a helper function.
Insert the tilde ASCII value (126, which translates to "~") after every integer less than 48. Hint: Append more than once.
Convert the list of integers back to a string using chr.
The decrypt_text function should consume the encrypted message (a string) and rotation_amount (an integer) and produces a string where the text is decrypted as follows:
Convert the string to a list of integers using ord.
Filter the list to remove any occurrence of the value 126(the tilde "~").
The integers in the list are rotated -rotation_amount amount.
Convert the list of integers back to a string using chr.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!