Tres Seaver
2009-05-08 d6fbd4fc4c75152276ec816837db2330cafd47f9
Suppress deprecation on Python 2.5 / 2.6 by preferring hashlib.
1 files modified
7 ■■■■ changed files
repoze/who/plugins/sql.py 7 ●●●● patch | view | raw | blame | history
repoze/who/plugins/sql.py
@@ -4,14 +4,17 @@
from repoze.who.interfaces import IMetadataProvider
def default_password_compare(cleartext_password, stored_password_hash):
    import sha
    try:
        from hashlib import sha1
    except ImportError: # Python < 2.5
        from sha import new as sha1
    # the stored password is stored as '{SHA}<SHA hexdigest>'.
    # or as a cleartext password (no {SHA} prefix)
    if stored_password_hash.startswith('{SHA}'):
        stored_password_hash = stored_password_hash[5:]
        digest = sha.new(cleartext_password).hexdigest()
        digest = sha1(cleartext_password).hexdigest()
    else:
        digest = cleartext_password