keystone.common.password_hashers.scrypt module

class keystone.common.password_hashers.scrypt.Scrypt[source]

Bases: PasswordHasher

passlib transition class for implementing scrypt password hashing

static hash(password: bytes, salt_size: int = 16, n: int = 16, r: int = 8, p: int = 1, **kwargs) str[source]

Generate password hash string with ident and params

https://docs.python.org/3/library/hashlib.html#hashlib.scrypt

Parameters:
  • password (bytes) – Password to be hashed.

  • salt_size (int) – Salt size.

  • n (int) – CPU/Memory cost factor.

  • r (int) – Block size.

  • p (int) – Parallel count.

Returns:

String in format $scrypt$ln=logN,r=R,p=P$salt$checksum

ident_values: set[str] = {'$7$', '$scrypt$'}
name: str = 'scrypt'
static verify(password: bytes, hashed: str) bool[source]

Verify hashing password would be equal to the hashed value

Parameters:
  • password (bytes) – Password to verify

  • hashed (string) – Hashed password. Used to extract hashing parameters

Returns:

boolean whether hashing password with the same parameters would match hashed value