module documentation

Undocumented

Class Argon2PasswordHasher Secure password hashing using the argon2 algorithm.
Class BasePasswordHasher Abstract base class for password hashers
Class BCryptPasswordHasher Secure password hashing using the bcrypt algorithm
Class BCryptSHA256PasswordHasher Secure password hashing using the bcrypt algorithm (recommended)
Class CryptPasswordHasher Password hashing using UNIX crypt (not recommended)
Class MD5PasswordHasher The Salted MD5 password hashing algorithm (not recommended)
Class PBKDF2PasswordHasher Secure password hashing using the PBKDF2 algorithm (recommended)
Class PBKDF2SHA1PasswordHasher Alternate PBKDF2 hasher which uses SHA1, the default PRF recommended by PKCS #5. This is compatible with other implementations of PBKDF2, such as openssl's PKCS5_PBKDF2_HMAC_SHA1().
Class ScryptPasswordHasher Secure password hashing using the Scrypt algorithm.
Class SHA1PasswordHasher The SHA1 password hashing algorithm (not recommended)
Class UnsaltedMD5PasswordHasher Incredibly insecure algorithm that you should *never* use; stores unsalted MD5 hashes without the algorithm prefix, also accepts MD5 hashes with an empty salt.
Class UnsaltedSHA1PasswordHasher Very insecure algorithm that you should *never* use; store SHA1 hashes with an empty salt.
Function check_password Return a boolean of whether the raw password matches the three part encoded digest.
Function get_hasher Return an instance of a loaded password hasher.
Function get_hashers Undocumented
Function get_hashers_by_algorithm Undocumented
Function identify_hasher Return an instance of a loaded password hasher.
Function is_password_usable Return True if this password wasn't generated by User.set_unusable_password(), i.e. make_password(None).
Function make_password Turn a plain-text password into a hash for database storage
Function mask_hash Return the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons.
Function must_update_salt Undocumented
Function reset_hashers Undocumented
Constant UNUSABLE_PASSWORD_PREFIX Undocumented
Constant UNUSABLE_PASSWORD_SUFFIX_LENGTH Undocumented
def check_password(password, encoded, setter=None, preferred='default'): (source)

Return a boolean of whether the raw password matches the three part encoded digest. If setter is specified, it'll be called when you need to regenerate the password.

def get_hasher(algorithm='default'): (source)

Return an instance of a loaded password hasher. If algorithm is 'default', return the default hasher. Lazily import hashers specified in the project's settings file if needed.

Undocumented

@functools.lru_cache
def get_hashers_by_algorithm(): (source)

Undocumented

def identify_hasher(encoded): (source)

Return an instance of a loaded password hasher. Identify hasher algorithm by examining encoded hash, and call get_hasher() to return hasher. Raise ValueError if algorithm cannot be identified, or if hasher is not loaded.

def is_password_usable(encoded): (source)

Return True if this password wasn't generated by User.set_unusable_password(), i.e. make_password(None).

def make_password(password, salt=None, hasher='default'): (source)

Turn a plain-text password into a hash for database storage Same as encode() but generate a new random salt. If password is None then return a concatenation of UNUSABLE_PASSWORD_PREFIX and a random string, which disallows logins. Additional random string reduces chances of gaining access to staff or superuser accounts. See ticket #20079 for more info.

def mask_hash(hash, show=6, char='*'): (source)

Return the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons.

def must_update_salt(salt, expected_entropy): (source)

Undocumented

@receiver(setting_changed)
def reset_hashers(*, setting, **kwargs): (source)

Undocumented

UNUSABLE_PASSWORD_PREFIX: str = (source)

Undocumented

Value
'!'
UNUSABLE_PASSWORD_SUFFIX_LENGTH: int = (source)

Undocumented

Value
40