-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypt.py
More file actions
27 lines (20 loc) · 694 Bytes
/
encrypt.py
File metadata and controls
27 lines (20 loc) · 694 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
result = ''
message = ''
choice = ''
while choice != 0:
choice = input("\nWould you like to encrypt or decrypt the message?\nEnter 1 to encrypt, or 2 to decrypt. Enter 0 to exit program.")
if choice == '1':
message = input("\nEnter message for encryption: ")
for i in range(0, len(message)):
result = result + chr(ord(message[i]) - 3)
print(result + '\n\n')
result = ''
elif choice == '2':
message = input("\nEnter a message for decryption: ")
for i in range(0, len(message)):
result = result + chr(ord(message[i]) + 3)
print(result + '\n\n')
result = ''
elif choice != '0':
print("Invalid input. Please try again. \n\n")
# Tutorial provided by David Kaplan