possibilité de spécifier le salt
This commit is contained in:
parent
6b746a83bc
commit
b750422b94
|
@ -124,10 +124,10 @@ def gen_binary_hash(pw, scheme, salt=None):
|
|||
|
||||
return base64.b64encode(hash)
|
||||
|
||||
def gen_hash(pw, scheme=None, ref=None, normalized=True):
|
||||
def gen_hash(pw, scheme=None, ref=None, salt=None, normalized=True):
|
||||
if ref is not None:
|
||||
scheme = get_scheme(ref)
|
||||
salt = get_salt(ref)
|
||||
if salt is None: salt = get_salt(ref)
|
||||
if is_crypt_scheme(scheme):
|
||||
hash = gen_crypt_hash(pw, salt)
|
||||
else:
|
||||
|
@ -135,12 +135,12 @@ def gen_hash(pw, scheme=None, ref=None, normalized=True):
|
|||
elif scheme is not None:
|
||||
scheme = get_scheme(scheme)
|
||||
if is_crypt_scheme(scheme):
|
||||
hash = gen_crypt_hash(pw)
|
||||
hash = gen_crypt_hash(pw, salt)
|
||||
else:
|
||||
hash = gen_binary_hash(pw, scheme)
|
||||
hash = gen_binary_hash(pw, scheme, salt)
|
||||
else:
|
||||
# Par défaut, hasher en crypt
|
||||
scheme = '{CRYPT}'
|
||||
hash = gen_crypt_hash(pw)
|
||||
hash = gen_crypt_hash(pw, salt)
|
||||
if normalized: hash = scheme + hash
|
||||
return hash
|
||||
|
|
Loading…
Reference in New Issue