-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab6.py
35 lines (32 loc) · 1.08 KB
/
lab6.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
# Daniel Rodriguez
# 10/22/2024
# Encode string of 8 numbers by shifting each digit up by 3
def encode(pwd):
encoded_pwd = ''
for digit in pwd:
encoded_pwd += str(int(digit) + 3)
return encoded_pwd
def decoder(inputPassword):
decodedPassword = ""
for i in range(0, len(inputPassword)):
decodedPassword = decodedPassword + str(int(inputPassword[i]) - 3)
return decodedPassword
if __name__ == '__main__':
encoded_pwd = None
while True:
print('Menu')
print('------')
print('1. Encode')
print('2. Decode')
print('3. Quit\n')
option = int(input('Please enter an option: '))
if option == 1:
pwd = input('Please enter your password to encode: ')
encoded_pwd = encode(pwd)
print('Your password has been encoded and stored!')
elif option == 2:
decoded_pwd = decoder(encoded_pwd)
print(f'The encoded password is {encoded_pwd}, and the original password is {decoded_pwd}.')
elif option == 3:
break
print()