Created
June 26, 2020 02:24
-
-
Save shadowdevnotreal/d837c7104786d2eee886b03986d3cda4 to your computer and use it in GitHub Desktop.
Simple Caesar Shifting Decryption Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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