summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/wiki/src/tests')
-rw-r--r--docs/tutorials/wiki/src/tests/tutorial/security.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/tutorials/wiki/src/tests/tutorial/security.py b/docs/tutorials/wiki/src/tests/tutorial/security.py
index 4115c780c..cbb3acd5d 100644
--- a/docs/tutorials/wiki/src/tests/tutorial/security.py
+++ b/docs/tutorials/wiki/src/tests/tutorial/security.py
@@ -2,11 +2,13 @@ import bcrypt
def hash_password(pw):
- return bcrypt.hashpw(pw.encode('utf-8'), bcrypt.gensalt())
+ hashed_pw = bcrypt.hashpw(pw.encode('utf-8'), bcrypt.gensalt())
+ # return unicode instead of bytes because databases handle it better
+ return hashed_pw.decode('utf-8')
def check_password(expected_hash, pw):
if expected_hash is not None:
- return bcrypt.checkpw(pw.encode('utf-8'), expected_hash)
+ return bcrypt.checkpw(pw.encode('utf-8'), expected_hash.encode('utf-8'))
return False
USERS = {'editor': hash_password('editor'),