-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesarshift.py
More file actions
32 lines (26 loc) · 758 Bytes
/
Copy pathcaesarshift.py
File metadata and controls
32 lines (26 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
key = 0
message = input('Message to Decrypt: \n')
def selectkey():
global key
key = input('Enter the key you want to try: \n')
print('\n')
def decrypt():
global key
for symbol in message:
if symbol.isalpha():
numcode = ord(symbol)
numcode -= int(key)
if symbol.isupper():
if numcode > ord('Z'):
numcode -= 26
elif numcode < ord('A'):
numcode += 26
elif symbol.islower():
if numcode > ord('z'):
numcode -= 26
elif numcode < ord('a'):
numcode += 26
letter = chr(numcode)
print(letter)
selectkey()
decrypt()