def hashPasswordTuple(password, digestMod=hashlib.sha512, iterations=10000,
saltSize=32):
"""
Module function to hash a password according to the PBKDF2 specification.
@param password clear text password (string)
@param digestMod hash function
@param iterations number of times hash function should be applied (integer)
@param saltSize size of the salt (integer)
@return tuple of digestname (string), number of iterations (integer),
salt (bytes) and hashed password (bytes)
"""
salt = os.urandom(saltSize)
password = password.encode("utf-8")
hash = pbkdf2(password, salt, iterations, digestMod)
digestname = digestMod.__name__.replace("openssl_", "")
return digestname, iterations, salt, hash
评论列表
文章目录