123456789101112131415161718 |
- def hash_pw(password):
- """
- Hashes the given password using scrypt and a random salt
- :param password: password to hash
- :returns: hashed password with arguments
- """
- salt = gen_rand_string()
- pw_hash = base64.b64encode(
- hmac.new(
- key=salt.encode('utf8'),
- msg=password.encode('utf8'),
- digestmod='SHA256'
- ).digest()
- ).decode('utf8')
- return implode(pw_hash, salt)
|