mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Fix algorithm presence detection
This commit is contained in:
parent
9da8bdd342
commit
78f7826521
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user