aboutsummaryrefslogtreecommitdiff
path: root/api/passwords.py
blob: 9cd56da3220176caa41e050535c4badc9076a6c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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())