-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab_6.py
43 lines (32 loc) · 957 Bytes
/
Lab_6.py
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
33
34
35
36
37
38
39
40
41
42
43
def encode(password):
encoded = ""
for i in password:
digit = int(i) + 3
encoded += str(digit)
return encoded
def decode(password):
decoded = ""
for i in password:
digit = int(i) - 3
decoded += str(digit)
return decoded
def main():
encoded = None
while True:
print("Menu")
print("-------------")
print("1. Encode")
print("2. Decode")
print("3. Quit")
print()
menu_selection = int(input("Please enter an option: "))
if menu_selection == 1:
password = input("Please enter your password to encode: ")
encoded = encode(password)
elif menu_selection == 2:
decoded = decode(encoded)
print("The encoded password is " + encoded + " and the original password is " + decoded + ".")
elif menu_selection == 3:
break
if __name__ == "__main__":
main()