Skip to content

Reference - Hashers

pwdlib.hashers.argon2

Argon2Hasher

Bases: HasherProtocol

__init__(time_cost=argon2.DEFAULT_TIME_COST, memory_cost=argon2.DEFAULT_MEMORY_COST, parallelism=argon2.DEFAULT_PARALLELISM, hash_len=argon2.DEFAULT_HASH_LENGTH, salt_len=argon2.DEFAULT_RANDOM_SALT_LENGTH, type=argon2.Type.ID)

Parameters:

Name Type Description Default
time_cost int

Defines the amount of computation realized and therefore the execution time, given in number of iterations.

DEFAULT_TIME_COST
memory_cost int

Defines the memory usage, given in kibibytes.

DEFAULT_MEMORY_COST
parallelism int

Defines the number of parallel threads (changes the resulting hash value).

DEFAULT_PARALLELISM
hash_len int

Length of the hash in bytes.

DEFAULT_HASH_LENGTH
salt_len int

Length of random salt to be generated for each password.

DEFAULT_RANDOM_SALT_LENGTH
type Type

Argon2 type to use. Only change for interoperability with legacy systems.

ID

pwdlib.hashers.bcrypt

BcryptHasher

Bases: HasherProtocol

__init__(rounds=12, prefix='2b')

Parameters:

Name Type Description Default
rounds int

The number of rounds to use for hashing.

12
prefix Literal['2a', '2b']

The prefix to use for hashing.

'2b'