Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def encrypt(plaintext, shift): The encrypt function. The encryption scheme is to substitute each alphabet in the string with another alphabet shift shifts to its left.

image text in transcribed

def encrypt(plaintext, shift): """The encrypt function.

The encryption scheme is to substitute each alphabet in the string with another alphabet "shift" shifts to its left. For example, if shift = 3, Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW If the plaintext contains spaces, they occur as themselves in the cipher. """ cipher = "" """Write your code here to calucate the cipher""" return cipher

if __name__ == "__main__": plaintext = input() shift = int(input()) cipher = encrypt(plaintext, shift) print(cipher)

9.13 LAB: The Caesar cipher In cryptography, Caesar's cipher is one of the simplest and most widely known encryption techniques. The method is named after Julius Caesar, who used it in his private communication. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. We wish to implement Caesar's encryption scheme by substituting each alphabet in the string with another alphabet that occurs three shifts to its left. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. Note that that the code wraps around in that A would be replaced by X, B would be replaced byX and C would be replaced by Z. Write a function called encrypt that takes two input arguments: the plaintext and the number of left shifts to use when constructing the cipher, and returns the encrypted string. For example, if the user enters plaintext "CAME I SAW I CONQUERED" and shift 3, then cipher= encrypt (plaintext, shift) should return as the cipher. Also, note that white spaces in the plaintext occur as themselves in the cipher as well. Finally, your code must work correctly for lower case letters as well as a mix of upper and lower case letters. For example, if plaintext "came I saw I conquered and shift 3, then cipher= encrypt (plaintext, shift) should return F zxjb F pxt F zlknrboba as the cipher

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago