Caesar
Caesar
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