-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting test test.py
423 lines (390 loc) · 19.3 KB
/
testing test test.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
import time
loopi = True
global k
k = 0
error_message = "\u001b[31mError: Invalid Response\u001b[0m"
loop_signup = False
loop_login = False
back_security = False
user_list = {
}
while loopi is True:
global username
global password
global password_new
global password_ask
global pass_check_change
loop_start = input("Hello! Do you want to sign up or log in? ")
starter = True
security_start = False
loop_signup = False
loop_login = False
back_security = False
loop_dec = False
repeat_acc = False
Task_settings = False
user_pass = False
weak = True
x = 40*"\n"
def change_password_l(juser):
global password
global password_new
juser.pop(user_check_change)
juser[user_check_change] = password_new
def change_password(juser):
global user_check_change
global password_new
juser.pop(user_check_change)
juser[user_check_change] = password_new
def user_create(juser):
juser[username] = password
return k
def pass_encryption(x):
re = str(x.replace("a", "!"))
re = str(re.replace("b", "@"))
re = str(re.replace("c", "#"))
re = str(re.replace("d", "$"))
re = str(re.replace("e", "("))
re = str(re.replace("f", "_"))
re = str(re.replace("g", "3"))
re = str(re.replace("h", "/"))
re = str(re.replace("i", "{"))
re = str(re.replace("j", "B"))
re = str(re.replace("k", "p"))
re = str(re.replace("l", "&"))
re = str(re.replace("m", "4"))
re = str(re.replace("n", "q"))
re = str(re.replace("o", "="))
re = str(re.replace("p", "Z"))
re = str(re.replace("q", "["))
re = str(re.replace("r", "J"))
re = str(re.replace("s", "2"))
re = str(re.replace("t", "w"))
re = str(re.replace("u", "v"))
re = str(re.replace("v", "M"))
re = str(re.replace("w", "L"))
re = str(re.replace("x", "+"))
re = str(re.replace("y", "\\"))
re = str(re.replace("z", "\""))
re = str(re.replace("1", "O"))
re = str(re.replace("2", "."))
re = str(re.replace("3", "j"))
re = str(re.replace("4", "?"))
re = str(re.replace("5", "S"))
re = str(re.replace("6", "}"))
re = str(re.replace("7", "Y"))
re = str(re.replace("8", "W"))
re = str(re.replace("9", "Q"))
re = str(re.replace("0", "%"))
re = str(re.replace("!", "1"))
re = str(re.replace("@", "T"))
re = str(re.replace("#", "U"))
re = str(re.replace("$", "9"))
re = str(re.replace("%", "G"))
re = str(re.replace("^", "P"))
re = str(re.replace("^", "N"))
re = str(re.replace("&", "*"))
re = str(re.replace("*", "&"))
re = str(re.replace("(", "-"))
re = str(re.replace(")", "H"))
re = str(re.replace("_", "="))
re = str(re.replace("-", "8"))
re = str(re.replace("+", "{"))
re = str(re.replace("=", "X"))
re = str(re.replace("|", "R"))
re = str(re.replace("\\", "H"))
re = str(re.replace("{", ";"))
re = str(re.replace("[", "]"))
re = str(re.replace("]", "["))
re = str(re.replace("}", "("))
return re
i = bool(loop_start)
lowerloop_start = str(loop_start.lower())
if starter is True and lowerloop_start == "sign up" or lowerloop_start == "signup":
starter = False
print("\n\u001b[37mDO NOT MAKE YOUR USERNAME AND PASSWORD THE SAME FOR SECURITY REASONS")
username = input("Username: ")
print("\n ")
print("(Your password will be encrypted after you make an account and until you want it to be decrypted)")
password = input("Password: \u001b[0m")
if username in user_list and bool(user_list) is True:
print("\u001b[31mUsername already taken\u001b[0m")
repeat_acc = True
time.sleep(2)
print(x)
if username == password:
user_pass = True
print("\u001b[31mYour username and password cannot be the same\u001b[0m")
time.sleep(2)
print(x)
elif username != password:
user_pass = False
if password in user_list.values():
print("\u001b[31mWeak password. Try a different one.\u001b[0m")
time.sleep(2)
print(x)
weak = False
elif password not in user_list:
weak = True
encrypted_password = pass_encryption(password)
encrypted_username = pass_encryption(username)
if repeat_acc is False and user_pass is False and weak is True:
user_create(user_list)
loop_signup = True
elif repeat_acc is True:
loop_signup = False
if user_pass is True:
loop_signup = False
if weak is False:
loop_signup = False
while loop_signup is True:
encrypted_username = pass_encryption(username)
encrypted_password = pass_encryption(password)
back_security = True
print(x)
print("Menu")
print("---------------------------------------------------------")
print("Settings\nSecurity\n\u001b[31mLOG OUT\u001b[0m")
Taskl = input("What do you want to select? ")
lowerTaskl = str(Taskl.lower())
if lowerTaskl == "log out" or lowerTaskl == "logout":
print(x)
loop_signup = False
elif lowerTaskl == "security":
security_start = True
while security_start is True:
back_security = True
loop_dec = False
print(x)
print("Security")
print("---------------------------------------------------------")
print("Encrypted Username: " + encrypted_username)
print("Encrypted Password: " + encrypted_password)
print("\u001b[37mDecrypt\u001b[0m")
print("\u001b[37mChange Password\u001b[0m")
print("\u001b[31mBACK\u001b[0m")
if back_security is True:
Task_security = input("What do you want to select? ")
Task_security_lower = Task_security.lower()
if Task_security_lower == "back" and back_security is True:
break
elif Task_security_lower == "change password" or Task_security_lower == "changepassword" and back_security is True:
print("To carry this function out, you will need to enter your account information")
user_check_change = input("\u001b[37mUsername: ")
pass_check_change = input("Password: \u001b[0m")
if user_check_change in user_list and user_list.get(user_check_change) == pass_check_change:
print(x)
password_new = input("\u001b[37mWhat would you like to change your password to? \u001b[0m")
if password_new in user_list.values():
print("\u001b[31mWeak password. Try a different one.\u001b[0m")
time.sleep(2)
print(x)
elif password_new not in user_list.values():
change_password(user_list)
encrypted_username = pass_encryption(username)
encrypted_password = pass_encryption(password_new)
password = password_new
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
elif Task_security_lower == "decrypt":
print("To carry this function out, you will need to enter your account information")
user_check = input("\u001b[37mUsername: ")
pass_check = input("Password: \u001b[0m")
if user_check in user_list and user_list.get(user_check) == pass_check:
loop_dec = True
break
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
else:
print(error_message)
time.sleep(2)
while loop_dec is True:
encrypted_username = pass_encryption(username)
encrypted_password = pass_encryption(password)
print(x)
print("\u001b[0mSecurity")
print("---------------------------------------------------------")
print("Username: " + username)
print("Password: " + password)
print("\u001b[37mChange Password\u001b[0m")
print("\u001b[31mBACK\u001b[0m")
Task_security = input("What do you want to select? ")
Task_security_lower = Task_security.lower()
if Task_security_lower == "back" and back_security is True:
break
elif Task_security_lower == "change password" or Task_security_lower == "changepassword" and back_security is True:
print("To carry this function out, you will need to enter your account information")
user_check_change = input("\u001b[37mUsername: ")
pass_check_change = input("Password: \u001b[0m")
if user_check_change in user_list and user_list.get(user_check_change) == pass_check_change:
print(x)
password_new = input("\u001b[37mWhat would you like to change your password to? \u001b[0m")
if password_new not in user_list.values():
change_password(user_list)
password = password_new
elif password_new in user_list.values():
print("\u001b[31mWeak password. Try a different one.\u001b[0m")
time.sleep(2)
print(x)
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
else:
print(error_message)
time.sleep(2)
elif lowerTaskl == "settings":
Task_settings = True
while Task_settings is True:
print(x)
print("\u001b[0mNothing here yet!\u001b[0m")
print("\u001b[31mBACK\u001b[0m")
Task_setting_task = input("\u001b[0mWhat do you want to select? \u001b[0m")
Task_setting_task_lower = Task_setting_task.lower()
if Task_setting_task_lower == "back":
break
else:
print(error_message)
time.sleep(2)
else:
print(error_message)
time.sleep(2)
elif starter is True and lowerloop_start == "login" or lowerloop_start == "log in" and bool(user_list) is False:
print("\u001b[31mError: No user accounts have been made yet\u001b[0m")
starter = False
time.sleep(2)
print(x)
elif starter is True and lowerloop_start == "login" or lowerloop_start == "log in" and bool(user_list) is True:
starter = False
username_ask = input("\u001b[37mUsername: ")
print("\n ")
print("(Your password will be encrypted after you make an account and until you want it to be decrypted)")
password_ask = input("Password: \u001b[0m")
encrypted_username = pass_encryption(username_ask)
encrypted_password = pass_encryption(password_ask)
if user_list.get(username_ask) == password_ask:
loop_login = True
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
print(x)
while loop_login is True:
print(x)
print("Menu")
print("---------------------------------------------------------")
print("Settings\nSecurity\n\u001b[31mLOG OUT\u001b[0m")
Task = input("What do you want to select? ")
lowerTask = str(Task.lower())
print(lowerTask)
if lowerTask == "log out" or lowerTask == "logout":
print(x)
loop_login = False
elif lowerTask == "settings":
print("john likes pie:)))")
Task_settings = True
while Task_settings is True:
print(x)
print("\u001b[0mNothing here yet!\u001b[0m")
print("\u001b[31mBACK\u001b[0m")
Task_setting_task = input("\u001b[0mWhat do you want to select? \u001b[0m")
Task_setting_task_lower = Task_setting_task.lower()
if Task_setting_task_lower == "back":
break
else:
print(error_message)
time.sleep(2)
elif lowerTask == "security":
security_start = True
while security_start is True:
back_security = True
loop_dec = False
print(x)
print("Security")
print("---------------------------------------------------------")
print("Encrypted Username: " + encrypted_username)
print("Encrypted Password: " + encrypted_password)
print("\u001b[37mDecrypt\u001b[0m")
print("\u001b[37mChange Password\u001b[0m")
print("\u001b[31mBACK\u001b[0m")
if back_security is True:
Task_security = input("What do you want to select? ")
Task_security_lower = Task_security.lower()
if Task_security_lower == "back" and back_security is True:
break
elif Task_security_lower == "change password" or Task_security_lower == "changepassword" and back_security is True:
print("To carry this function out, you will need to enter your account information")
user_check_change = input("\u001b[37mUsername: ")
pass_check_change = input("Password: \u001b[0m")
if user_check_change in user_list and user_list.get(user_check_change) == pass_check_change:
print(x)
password_new = input("\u001b[37mWhat would you like to change your password to? \u001b[0m")
if password_new not in user_list.values():
change_password_l(user_list)
password_ask = password_new
encrypted_username = pass_encryption(username_ask)
encrypted_password = pass_encryption(password_ask)
elif password in user_list.values():
print("\u001b[31mWeak password. Try a different one.\u001b[0m")
time.sleep(2)
print(x)
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
elif Task_security_lower == "decrypt":
print("To carry this function out, you will need to enter your account information")
user_check = input("\u001b[37mUsername: ")
pass_check = input("Password: \u001b[0m")
if user_check in user_list and user_list.get(user_check) == pass_check:
loop_dec = True
break
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
else:
print(error_message)
time.sleep(2)
while loop_dec is True:
encrypted_username = pass_encryption(username_ask)
encrypted_password = pass_encryption(password_ask)
print(x)
print("\u001b[0mSecurity")
print("---------------------------------------------------------")
print("Username: " + username)
print("Password: " + password_ask)
print("\u001b[37mChange Password\u001b[0m")
print("\u001b[31mBACK\u001b[0m")
Task_security = input("What do you want to select? ")
Task_security_lower = Task_security.lower()
if Task_security_lower == "back" and back_security is True:
break
elif Task_security_lower == "change password" or Task_security_lower == "changepassword" and back_security is True:
print("To carry this function out, you will need to enter your account information")
user_check_change = input("\u001b[37mUsername: ")
pass_check_change = input("Password: \u001b[0m")
if user_check_change in user_list and user_list.get(user_check_change) == pass_check_change:
print(x)
password_new = input("\u001b[37mWhat would you like to change your password to? \u001b[0m")
if password_new in user_list.values():
print("\u001b[31mWeak password. Try a different one.\u001b[0m")
time.sleep(2)
print(x)
elif password_new not in user_list.values():
change_password_l(user_list)
password_ask = password_new
else:
print("\u001b[31mWrong username or password\u001b[0m")
time.sleep(2)
else:
print(error_message)
time.sleep(2)
else:
print(error_message)
time.sleep(2)
elif starter is True or lowerloop_start != "sign up" or lowerloop_start != "signup" or lowerloop_start != "login" or lowerloop_start != "log in":
error_message.strip()
print(error_message)
time.sleep(2)
print(x)
i = True
starter = False