-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab6.py
More file actions
37 lines (30 loc) · 977 Bytes
/
Lab6.py
File metadata and controls
37 lines (30 loc) · 977 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
# Ricky Hou
def encode(orig_pass):
result = ''
for numbers in orig_pass:
new_numbers = str((int(numbers) + 3) % 10)
result += new_numbers
return result
def decode(password):
result = ''
for numbers in password:
new_numbers = str((int(numbers) - 3) % 10)
result += new_numbers
return result
def main():
testing = True
while testing:
print("Menu")
print("-------------")
print("1. Encode\n2. Decode\n3. Quit\n")
option = int(input("Please enter an option:"))
if option == 1:
orig_pass = input("Please enter your password to encode:")
orig_pass = encode(orig_pass)
print("Your password has been encoded and stored!\n")
elif option == 2:
print(f"The encoded password is {orig_pass}, and the original password is {decode(orig_pass).")
else:
testing = False
if __name__ == "__main__":
main()