Skip to content

Instantly share code, notes, and snippets.

@shadowdevnotreal
Created June 26, 2020 02:24
Show Gist options
  • Select an option

  • Save shadowdevnotreal/d837c7104786d2eee886b03986d3cda4 to your computer and use it in GitHub Desktop.

Select an option

Save shadowdevnotreal/d837c7104786d2eee886b03986d3cda4 to your computer and use it in GitHub Desktop.
Simple Caesar Shifting Decryption Script
#Caesar Shift Decryption Code
def encrypt(string, shift):
cipher = ''
for char in string:
if char == ' ':
cipher = cipher + char
elif char.isupper():
cipher = cipher + chr((ord(char) - shift - 65) % 26 + 65)
else:
cipher = cipher + chr((ord(char) - shift - 97) % 26 + 97)
return cipher
text = input("enter string: ")
s = int(input("enter shift number: "))
print("original string: ", text)
print("after encryption: ", encrypt(text, s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment