-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchas_code.py
68 lines (53 loc) · 1.65 KB
/
chas_code.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def encode(password):
total = ''
for item in str(password):
if int(item) < 7:
total += (str(int(item) + 3))
if item == '7':
total += '0'
elif item == '8':
total += '1'
elif item == '9':
total += '2'
return total
def decode(code): ## Darvan Cherichel
pass_decode=""
for digit in code:
if digit == "1":
pass_decode+="8"
elif digit =="2":
pass_decode="9"
elif digit=="3":
pass_decode+="0"
elif digit=="4":
pass_decode+="1"
elif digit=="5":
pass_decode+="2"
elif digit=="6":
pass_decode+="3"
elif digit=="7":
pass_decode+="4"
elif digit=="8":
pass_decode+="5"
elif digit=="9":
pass_decode+="6"
elif digit=="0":
pass_decode+="7"
return pass_decode
if __name__ == '__main__':
while True:
print('\nMenu')
print('-------------')
print('1. Encode\n2. Decode\n3. Quit')
print()
menu_option = int(input('Please enter an option: '))
if menu_option == 1:
global password
password = int(input('Please enter your password to encode: '))
print('Your password has been encoded and stored!')
password = encode(password)
continue
if menu_option == 2:
print(f'The encoded password is {password}, and the original password is {decode(password)}.')
if menu_option == 3:
break