blob: 8fa15c37ec80dcc5b3881c9d727dce1e64e82176 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import bcrypt
# encode string as utf-8
def enc(string):
return string.encode('utf-8')
# check if password matches against hash in database
def check_password(password, password_hash):
return bcrypt.checkpw(enc(password), password_hash)
# hash a password for storing in the database
def password_hash(password):
return bcrypt.hashpw(enc(password), bcrypt.gensalt())
|