Module crypto
Django's standard crypto functions and utilities.
source linkClasses
Functions
▶ def get_random_string(length=NOT_PROVIDED, ...) Return a securely generated random string.
def get_random_string(
length=NOT_PROVIDED,
allowed_chars='abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
)
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
Reexports
▶ def pbkdf2(password, salt, iterations, dklen=0, digest=None) Return the hash of password using pbkdf2.
▶ def salted_hmac(key_salt, value, secret=None, *, algorithm='sha1') 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.
Reexports