Program Specifications: Your task is to write a program that can decrypt a message that has been encoded using a Caesarcipher. Stated another way, you need to find the “shift” for the cipher. Once you have the shift,you know the mapping so you can decrypt the message. the encryption code. use python. def encrypt(text, r): #abcdefghijklmnopqrstuvwxyz result = '' for i in range(len(text)): # Hello Khoor char = text[i] if char.isupper(): result = result + chr((ord(char) + r - 65 ) % 26 + 65) else: result = result + chr((ord(char) + r - 97) % 26 + 97) return result while True: msg = input("\n\tEnter a String / message e.g. Today is Thursday ") rotation = int(input("\n\tEnter number of rotation e.g. 3 ")) print("\n\tOriginal Message is==> ",msg," with rotation ",rotation, " The CypherText ", encrypt(msg,rotation))
Program Specifications: Your task is to write a program that can decrypt a message that has been encoded using a Caesarcipher. Stated another way, you need to find the “shift” for the cipher. Once you have the shift,you know the mapping so you can decrypt the message.
the encryption code. use python.
def encrypt(text, r): #abcdefghijklmnopqrstuvwxyz
result = ''
for i in range(len(text)): # Hello Khoor
char = text[i]
if char.isupper():
result = result + chr((ord(char) + r - 65 ) % 26 + 65)
else:
result = result + chr((ord(char) + r - 97) % 26 + 97)
return result
while True:
msg = input("\n\tEnter a String / message e.g. Today is Thursday ")
rotation = int(input("\n\tEnter number of rotation e.g. 3 "))
print("\n\tOriginal Message is==> ",msg," with rotation ",rotation, " The CypherText ", encrypt(msg,rotation))
No hand written and fast answer with explanation
Step by step
Solved in 2 steps