Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me with the third question? Write a function cipher(plaintext, n) to shift all characters in a string of text. Your function should

Can you help me with the third question?

Write a function cipher(plaintext, n) to shift all characters in a string of text. Your function should take 2 parameters, the plaintext to shift (a string) and the shift key n (an integer). Set up an accumulator variable (suggested name: ciphertext) in which to accumulate the result. Use a definite loop with the accumulator pattern to go through all characters in plaintext. For each character, call your shift_char function to obtain the shifted version of that character, which you will concatenate into ciphertext. Return the ciphertext after the loop. Here are some test cases: >>> cipher('time', 4) 'xmqi' >>> cipher('welcome to the machine', 19) 'pxevhfx mh max ftvabgx'

3>>Suppose you have some ciphertext (i.e., 'iuet kag iqdq tqdq', or 'prqhb') but you dont know which decryption key (i.e., the number of characters to shift) to use. Write a function called codebreaker(ciphertext) that will try all possible Caesar cipher shifts (there are only 26 to try) and print out each possible deciphering. One of them will stand out as a valid English phrase. Your program must re-use your cipher function from question 2 above.

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago

Question

Is SHRD compatible with individual career aspirations

Answered: 1 week ago