Question
Hello, I am working on a python programming assignment and I am having some trouble. I cant seem to figure out how to decrypt a
Hello, I am working on a python programming assignment and I am having some trouble. I cant seem to figure out how to decrypt a plain text Caesar cipher. Here are the instruction and below that is my code. PLEASE HELP!
Create a script that inputs a line of encrypted text and a distance value and outputs plaintext using a Caesar cipher.
The script should work for any printable characters.
An example of the program input and output is shown below:
Enter the coded text: Lipps${svph% Enter the distance value: 4 Hello world!
defdecrypt(encryptedText,distance):
plainText=''
foriinencryptedText:
newDistance=ord(i)-(distance%128)
ifnewDistance<0:
newDistance=128+newDistance
plainText=plainText+chr(newDistance)
returnplainText
encryptedText=input("Enterthecodedtext:")
distance=input("Enterthedistancevalue:")
print(decrypt(encryptedText,distance))
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