Fix bug with sha1 passwords (closes #570)

This commit is contained in:
Guillaume Ayoub 2011-08-09 11:34:10 +02:00
parent 41680cc5b6
commit 50cdbf6efb

View File

@ -52,7 +52,7 @@ def _crypt(hash_value, password):
def _sha1(hash_value, password): def _sha1(hash_value, password):
"""Check if ``hash_value`` and ``password`` match using sha1 method.""" """Check if ``hash_value`` and ``password`` match using sha1 method."""
hash_value = hash_value.replace("{SHA}", "").encode("ascii") hash_value = hash_value.replace("{SHA}", "").encode("ascii")
password = password.encode(config.get("htpasswd_encoding", "stock")) password = password.encode(config.get("encoding", "stock"))
sha1 = hashlib.sha1() # pylint: disable=E1101 sha1 = hashlib.sha1() # pylint: disable=E1101
sha1.update(password) sha1.update(password)
return sha1.digest() == base64.b64decode(hash_value) return sha1.digest() == base64.b64decode(hash_value)