keystone.common.password_hashers.bcrypt module¶
- class keystone.common.password_hashers.bcrypt.Bcrypt[source]¶
Bases:
PasswordHasherpasslib transition class for implementing bcrypt password hashing
- static hash(password: bytes, rounds: int = 12, **kwargs) str[source]¶
Generate password hash string with ident and params
https://pypi.org/project/bcrypt/
- Parameters:
password (bytes) – Password to be hashed.
round (int) – Count of rounds.
- Returns:
String in format $2b${rounds}${salt}{digest}
- ident_values: set[str] = {'$2$', '$2a$', '$2b$', '$2x$', '$2y$'}¶
- name: str = 'bcrypt'¶
- static needs_rehash(hashed: str, rounds: int = 12, **kwargs) bool[source]¶
Return True if hashed used a lower cost than
rounds.- Parameters:
hashed (str) – Stored password hash (modular crypt format).
rounds (int) – Target bcrypt cost (defaults to 12).
- Returns:
True when the hash should be upgraded on next login.
- 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
- class keystone.common.password_hashers.bcrypt.Bcrypt_sha256[source]¶
Bases:
PasswordHasherpasslib transition class for bcrypt_sha256 password hashing
- static hash(password: bytes, rounds: int = 12, **kwargs) str[source]¶
Generate password hash string with ident and params
https://pypi.org/project/bcrypt/
- Parameters:
password (bytes) – Password to be hashed.
round (int) – Count of rounds.
- Returns:
String in format $bcrypt-sha256$r={rounds},t={ident},v={version}${salt}${digest}
- ident_values: set[str] = {'$2a$', '$2b$'}¶
- name: str = 'bcrypt_sha256'¶
- static needs_rehash(hashed: str, rounds: int = 12, **kwargs) bool[source]¶
Return True if hashed used a lower cost than
rounds.- Parameters:
hashed (str) – Stored password hash.
rounds (int) – Target bcrypt cost (defaults to 12).
- Returns:
True when the hash should be upgraded on next login.
- prefix: str = '$bcrypt-sha256$'¶
- 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