def hash_password(password: str, salt: Optional[bytes] = None) -> HashAndSalt:
pepper = b'alchemists discovered that gold came from earth air fire and water'
salt = salt or secrets.token_bytes(16)
salted_pass = salt + password.encode('utf-8')
return hashlib.pbkdf2_hmac('sha512', salted_pass, pepper, 100000), salt
评论列表
文章目录