-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_password
More file actions
40 lines (33 loc) · 1.31 KB
/
Copy pathcheck_password
File metadata and controls
40 lines (33 loc) · 1.31 KB
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
@app.route('/password-validate', methods=['POST'])
def password_validate():
result = [{'msg': 'success'}, {'stat': '200 ok'}]
if request.method == 'POST':
password_validate = request.get_json()
password = password_validate['password']
l, u, p, d = 0, 0, 0, 0
s = password
if (len(s) >= 8):
for i in s:
# counting lowercase alphabets
if (i.islower()):
l += 1
# counting uppercase alphabets
if (i.isupper()):
u += 1
# counting digits
if (i.isdigit()):
d += 1
# counting the mentioned special characters
if (i == '@' or i == '$' or i == '_'):
p += 1
if (l >= 1 and u >= 1 and p >= 1 and d >= 1 and l + p + u + d == len(s)):
print("Valid Password")
return jsonify(
{'message': "valid Password",
"password_responce":"200",
})
else:
print("Invalid Password")
return jsonify(
{'message': "Invalid Password",
"password_responce":"401"})