module documentation

Django's standard crypto functions and utilities.

Exception InvalidAlgorithm Algorithm is not supported by hashlib.
Function constant_time_compare Return True if the two strings are equal, False otherwise.
Function get_random_string Return a securely generated random string.
Function pbkdf2 Return the hash of password using pbkdf2.
Function salted_hmac Return the HMAC of 'value', using a key generated from key_salt and a secret (which defaults to settings.SECRET_KEY). Default algorithm is SHA1, but any algorithm name supported by hashlib can be passed.
Constant RANDOM_STRING_CHARS Undocumented
def constant_time_compare(val1, val2): (source)

Return True if the two strings are equal, False otherwise.

def get_random_string(length, allowed_chars=RANDOM_STRING_CHARS): (source)

Return a securely generated random string. The bit length of the returned value can be calculated with the formula: log_2(len(allowed_chars)^length) For example, with default `allowed_chars` (26+26+10), this gives: * length: 12, bit length =~ 71 bits * length: 22, bit length =~ 131 bits

def pbkdf2(password, salt, iterations, dklen=0, digest=None): (source)

Return the hash of password using pbkdf2.

def salted_hmac(key_salt, value, secret=None, *, algorithm='sha1'): (source)

Return the HMAC of 'value', using a key generated from key_salt and a secret (which defaults to settings.SECRET_KEY). Default algorithm is SHA1, but any algorithm name supported by hashlib can be passed. A different key_salt should be passed in for every application of HMAC.

RANDOM_STRING_CHARS: str = (source)

Undocumented

Value
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'