-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
50 lines (38 loc) · 1.27 KB
/
main.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
44
45
46
47
48
49
50
# Anthony Villanueva
def encode(password):
encoded_password = ""
for digit in password:
new_digit = (int(digit) + 3)
if new_digit >= 10: # Digits over 7 have 2 digits
new_digit = (str(new_digit))[1]
encoded_password += str(new_digit)
return encoded_password
def decode(encoded):
decoded_password = ""
for i in encoded:
if int(i)>=3:
decoded_password += str(int(i)-3)
elif int(i)<3:
decoded_password += str(int(i)+7)
return decoded_password
def main():
while True:
print("Menu")
print("-------------")
print("1. Encode")
print("2. Decode")
print("3. Quit\n")
option = input("Please enter an option: ")
if option == "1":
password = input("Please enter your password to encode: ")
encoded_pass = encode(password)
print("Your password has been encoded and stored!\n")
elif option == "2":
decoded_pass = decode(encoded_pass)
print(f"The encoded password is {encoded_pass}, and the original password is {decoded_pass}.\n")
elif option == "3":
break
else:
print("Invalid option. Try again!\n")
if __name__ == '__main__':
main()