Fix algorithm presence detection

This commit is contained in:
Mike Place 2015-12-18 10:59:52 -07:00
parent 9da8bdd342
commit 78f7826521

View File

@ -50,11 +50,10 @@ def hash(value, algorithm='sha512'):
salt '*' random.hash 'I am a string' md5
'''
if hasattr(hashlib, 'algorithms'):
if algorithm in hashlib.algorithms:
hasher = hashlib.new(algorithm)
hasher.update(value)
out = hasher.hexdigest()
if hasattr(hashlib, 'algorithms') and algorithm in hashlib.algorithms:
hasher = hashlib.new(algorithm)
hasher.update(value)
out = hasher.hexdigest()
elif hasattr(hashlib, algorithm):
hasher = hashlib.new(algorithm)
hasher.update(value)