-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecryptor.py
More file actions
32 lines (28 loc) · 933 Bytes
/
decryptor.py
File metadata and controls
32 lines (28 loc) · 933 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
enc_message = input("Enter the encrypted message: \t")
key = int(input("Enter the key: \t"))
shift = input("\nShift to: \nL. Left \nR. Right \n\t\t")
orig_message = ""
print(f"The encrypted message is: \t{enc_message}")
for char in enc_message:
if char.isalpha():
char_decode = ord(char)
if shift == "L":
char_decode += key
else:
char_decode -= key
if char.isupper():
if char_decode > ord('Z'):
char_decode -= 26
if char_decode < ord('A'):
char_decode += 26
else:
if char_decode > ord('z'):
char_decode -= 26
if char_decode < ord('a'):
char_decode += 26
orig_message += chr(char_decode)
else:
orig_message += char
print("")
print(f"The encrypted message is: \t{enc_message}")
print(f"\nThe decrypted message is: {orig_message}")