aboutsummaryrefslogtreecommitdiff
path: root/api/passwords.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-03-28 12:19:28 +0200
committerlonkaars <l.leblansch@gmail.com>2021-03-28 12:19:28 +0200
commit2f4536d6b08b69168ebf3e718cbd8e3002b9af5a (patch)
tree5307692fb341d7f924ee9b73f3751e7e56cfb192 /api/passwords.py
parent1f897d3f5ad11178cf4776ae4070c9d3e832f5f3 (diff)
added comments
Diffstat (limited to 'api/passwords.py')
-rw-r--r--api/passwords.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/api/passwords.py b/api/passwords.py
index e2ae552..8fa15c3 100644
--- a/api/passwords.py
+++ b/api/passwords.py
@@ -1,10 +1,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())
+