Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use python method and easy way to solve this thank you! Question 2 [10 marks]: In this question, you will write a program to encrypt
Use python method and easy way to solve this thank you!
Question 2 [10 marks]: In this question, you will write a program to encrypt and decrypt a string using a simple substitution cipher. In particular, you will start by setting up an alphabet string "abcdefghijklmnopqrstuvwxyz" (note there is a space character at the end of this string) Next, input an offset and a phrase (another string) to be encrypted. The characters in the phrase must be characters from the alphabet that you defined above. The offset indicates how to encrypt each character. In particular, each character will be replaced in the new encrypted string by a character that is "offset" number of characters beyond it in the alphabet. If a character in the input string is "c" and the offset is 2 then the character in the encrypted string will be "e" (which occurs 2 letters later in the alphabet). Note that you need to handle wrap-around at the end of the alphabet. For example, if a character in the input string is "z", then the encrypted character will be "a" if the offset is 2. You can assume that the offset will be less than the number of characters in the alphabet. The encryption problem is divided into three parts. The fourth part is to reverse this process and therefore create a function to decrypt a string. To begin, set up your main program as the following #Main Program alpha - "abcdefghijklmnopqrstuvwxyz" offset-int (input ("Enter the offset: ")) phrase -input ("Enter the phrase to encrypt:")Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started