-
Notifications
You must be signed in to change notification settings - Fork 0
/
224458_password_Md Asifuzzaman Jishan.py
66 lines (54 loc) · 2.21 KB
/
224458_password_Md Asifuzzaman Jishan.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
import pickle
import time
from termcolor import colored
def change_pw():
while True:
new_password = input('Please set your password: \n')
if len(new_password) < 10:
print('Password has to have minimum 10 character.')
continue
else:
print('Congratulations!')
if new_password=="E":
continue
if new_password != input('Confirm password: \n'):
print(colored('Passwords must be equal to the previous password.','red'))
continue
pickle.dump(new_password, open(r'C:\Users\Jishan\OneDrive - Technische Universität Dortmund\Desktop\Final Assignment\pw_file.p', 'wb'))
print('Password successfully changed.')
return new_password
failures=0
exit_flag = False
while True:
try:
password = pickle.load(open(r'C:\Users\Jishan\OneDrive - Technische Universität Dortmund\Desktop\Final Assignment\pw_file.p', 'rb') )
except:
password = change_pw()
enter_password= input('Enter the password. (Or enter "E" to exit.)\n')
if enter_password == password:
while True:
option = input('Enter "P" to show secret file, Enter "C" to change the password, Enter "L" to lock, Enter "E" to exit the programm.\n').upper()
if option == "P":
secret_file = open(r'C:\Users\Jishan\OneDrive - Technische Universität Dortmund\Desktop\Final Assignment\password-20221001\secret_file.txt', 'r', encoding='utf8')
secret_file_content = secret_file.read()
print(secret_file_content)
secret_file.close()
continue
if option == "C":
password = change_pw()
if option == "L":
break
if option == "E":
exit_flag = True
break
print(colored('No valid not detected', 'red'))
if exit_flag :
break
elif enter_password == "E":
break
else:
failures += 1
if failures == 6:
time.sleep(10)
failures = 0
print(colored('Wrong Password!', 'red'))