-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (31 loc) · 996 Bytes
/
main.py
File metadata and controls
40 lines (31 loc) · 996 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
33
34
35
36
37
38
39
40
def encode(thing):
encoded = ''
for i in range(0, len(thing)):
digit = int(thing[1]) +3
if digit > 9:
digit = digit % 10
encoded += str(digit)
return thing
def decode(password):
decoded = ''
for i in range(0, len(password)):
digit = int(password[i]) - 3
if digit < 0:
digit = digit + 10
decoded += str(digit)
return decoded
def main():
encoded = True
while True:
print("Menu\n------------\n1. Encode\n2. Decode\n3. Quit\n")
menu_choice = int(input("Please enter an option: "))
if menu_choice == 1:
password = input("Please enter your password to encode: ")
encoded = encode(password)
elif menu_choice == 2:
decoded = decode(encoded)
print(f"The encoded password is {encoded} and the original password is {decoded}.")
elif menu_choice == 3:
break
if __name__ == "__main__":
main()