-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode_encode.py
More file actions
38 lines (34 loc) · 1022 Bytes
/
decode_encode.py
File metadata and controls
38 lines (34 loc) · 1022 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
def encode(password):
encoded_string = ""
for digit in str(password):
add_three = str(int(digit) + 3)
encoded_string += add_three
return encoded_string
def decode(encoded):
decode = ''
for char in encoded:
decoded_char = chr(ord(char) - 1)
decode += decoded_char
return decode
def main():
while True:
menu()
option = int(input("\nPlease enter an option: "))
if option == 1:
password = int(input("Please enter your password to encode: "))
encoded = encode(password)
print("Your password has been encoded and stored!")
elif option == 2:
original = decode(encoded)
print(f"The encoded password is {encoded}, and the original password is {original}.")
elif option == 3:
break
def menu():
print("\nMenu")
print("-------------")
print("1. Encode")
print("2. Decode")
print("3. Quit")
return
if __name__ == '__main__':
main()