Registration Challenge
Last updated
Last updated
import string
"""
Caesar Cipher:
ord for changing the character shape to decimal, and then abstract it from the decimal value of a in small letters,
and then use the mod with 26, and after all that add the value to the decimal value of a.
"""
def Caesar(String, shift):
shifting = ""
for i in String:
if i in string.ascii_lowercase:
shifting += chr((ord(i) - ord('a') + shift) % 26 + ord('a'))
elif i in string.ascii_uppercase:
shifting += chr((ord(i) - ord('A') + shift) % 26 + ord('A'))
else:
shifting += i
return shifting
String = input("Please Input Your Encoded String: ")
for i in range(26):
print(f"Encoded String: {String}")
print("Decoded String: " + Caesar(String, i) + "\n")