-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
38 lines (26 loc) · 983 Bytes
/
utils.py
File metadata and controls
38 lines (26 loc) · 983 Bytes
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
import re
import bcrypt
def hash_password(password):
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(password.encode(), salt)
return hashed_password.decode()
def passwordMatch(entered_password, stored_hash):
stored_hash_bytes = stored_hash.encode()
return bcrypt.checkpw(entered_password.encode(), stored_hash_bytes)
def strongPassword(password):
min_length = 10
require_uppercase = True
require_lowercase = True
require_digit = True
require_special_char = True
if len(password) < min_length:
return False
if require_uppercase and not any(char.isupper() for char in password):
return False
if require_lowercase and not any(char.islower() for char in password):
return False
if require_digit and not any(char.isdigit() for char in password):
return False
if require_special_char and not re.search(r"[!@#$%^&*(),.?\":{}|<>]", password):
return False
return True