-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (40 loc) · 1.32 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
#Noah Lunberry COP3502C
def encode(unencoded):
# Noah Lunberry COP3502C
templist = list(unencoded)
newlist = []
for i in templist:
encoded_char = str((int(i) + 3) % 10) # ensure the result is within the digit range (0-9)
newlist.append(encoded_char)
return ''.join(newlist)
# August McDaniel COP3502C
def decode(encoded_password):
templist = list(encoded_password)
newlist = []
for i in templist:
encoded_char = str((int(i) - 3) % 10)
newlist.append(encoded_char)
return ''.join(newlist)
def main():
x = True
encoded_password = None
while x:
print('Menu')
print('-------------')
print('1. Encode')
print('2. Decode')
print('3. Quit')
print()
choice = int(input('Please enter an option: '))
if choice == 1:
unencoded = input('Please enter your password to encode: ')
encoded_password = encode(unencoded)
print('Your password has been encoded and stored!')
print()
elif choice == 2:
decoded_password = decode(str(encoded_password))
print(f'The encoded password is {encoded_password}, and the original password is {decoded_password}.')
elif choice == 3:
x = False
if __name__ == '__main__':
main()