0% found this document useful (0 votes)
1 views1 page

Caesar

Uploaded by

raphaelhaayo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Caesar

Uploaded by

raphaelhaayo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

def caesar_decrypt(cipher_text, shift):

decrypted_text = ""
for char in cipher_text:
if char.isalpha(): # Check if the character is a letter
shifted = ord(char) - shift
if char.isupper():
# Wrap around within uppercase letters (A-Z)
if shifted < ord('A'):
shifted += 26
decrypted_text += chr(shifted)
else:
# Wrap around within lowercase letters (a-z)
if shifted < ord('a'):
shifted += 26
decrypted_text += chr(shifted)
else:
decrypted_text += char # Keep spaces as is
return decrypted_text

# Decoding the received message with s = 5


encoded_message = "RTAJ TZY FY IFBS"
shift = 5
decoded_message = caesar_decrypt(encoded_message, shift)

# Print the output


print("Decoded message:", decoded_message)

You might also like