Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write all code in Python 15. There is a provably unbreakable cipher called a one-time pad. The way it works is you shift each character

image text in transcribed

Write all code in Python

15. There is a provably unbreakable cipher called a one-time pad. The way it works is you shift each character of the message by a random amount between 1 and 26 characters, wrapping around the alphabet if necessary. For instance, if the current character is y and the shift is 5, then the new character is d. Each character gets its own shift, so there needs to be as many random shifts as there are characters in the message. As an example, suppose the user enters secret. The program should generate a random shift between 1 and 26 for each character. Suppose the randomly generated shifts are 1,3, 2, 10, 8, and 2. The encrypted message would be thebmv (a) Write a program that asks the user for a message and encrypts the message using the one-time pad. First convert the string to lowercase. Any spaces and punctuation in the string should be left unchanged. For example, Secret!!! becomes thebmv!!! using the shifts above. (b) Write a program to decrypt a string encrypted as above. The reason it is called a one-time-pad is that the list of random shifts should only be used once It becomes easily breakable if the same random shifts are used for more than one message. Moreover, it is only provably unbreakable if the random numbers are truly random, and the numbers generated by randint are not truly random. For this problem, just use randint, but for cryptographically safe random numbers, see Section 22.8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions