module documentation

Undocumented

Function check​_password Return a boolean of whether the raw password matches the three part encoded digest.
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
Constant UNUSABLE​_PASSWORD​_PREFIX Undocumented
Constant UNUSABLE​_PASSWORD​_SUFFIX​_LENGTH Undocumented
Class ​Argon2​Password​Hasher Secure password hashing using the argon2 algorithm.
Class ​Base​Password​Hasher Abstract base class for password hashers
Class ​BCrypt​Password​Hasher Secure password hashing using the bcrypt algorithm
Class ​BCrypt​SHA256​Password​Hasher Secure password hashing using the bcrypt algorithm (recommended)
Class ​Crypt​Password​Hasher Password hashing using UNIX crypt (not recommended)
Class ​MD5​Password​Hasher The Salted MD5 password hashing algorithm (not recommended)
Class ​PBKDF2​Password​Hasher Secure password hashing using the PBKDF2 algorithm (recommended)
Class ​PBKDF2​SHA1​Password​Hasher No summary
Class ​Scrypt​Password​Hasher Secure password hashing using the Scrypt algorithm.
Class ​SHA1​Password​Hasher The SHA1 password hashing algorithm (not recommended)
Class ​Unsalted​MD5​Password​Hasher 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 ​Unsalted​SHA1​Password​Hasher Very insecure algorithm that you should never use; store SHA1 hashes with an empty salt.
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 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
def check_password(password, encoded, setter=None, preferred='default'):

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 is_password_usable(encoded):
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'):

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.

UNUSABLE_PASSWORD_PREFIX: str =

Undocumented

Value
'!'
UNUSABLE_PASSWORD_SUFFIX_LENGTH: int =

Undocumented

Value
40
def get_hasher(algorithm='default'):

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.

@functools.lru_cache()
def get_hashers():

Undocumented

@functools.lru_cache()
def get_hashers_by_algorithm():

Undocumented

def identify_hasher(encoded):

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 mask_hash(hash, show=6, char='*'):
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):

Undocumented

@receiver(setting_changed)
def reset_hashers(**kwargs):

Undocumented