Merge "Use sha512.hash() instead of .encrypt()"

This commit is contained in:
Jenkins 2016-11-29 15:47:24 +00:00 committed by Gerrit Code Review
commit cf5d5106fb
1 changed files with 2 additions and 8 deletions

View File

@ -132,14 +132,8 @@ def hash_user_password(user):
def hash_password(password):
"""Hash a password. Hard."""
password_utf8 = verify_length_and_trunc_password(password).encode('utf-8')
try:
return passlib.hash.sha512_crypt.encrypt(
password_utf8, rounds=CONF.crypt_strength)
except DeprecationWarning:
# TODO(stevemar): Remove this try/except once we switch over to passlib
# version 1.7.0 and replace encrypt() with hash()
return passlib.hash.sha512_crypt.hash(
password_utf8, rounds=CONF.crypt_strength)
return passlib.hash.sha512_crypt.hash(
password_utf8, rounds=CONF.crypt_strength)
def check_password(password, hashed):