make_password
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 make_password(
password: string|bytes|null,
salt: string = None,
hasher: string = "default"
) - > string
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.
Parameters
| Name | Type | Description |
|---|---|---|
| password | `string | bytes |
| salt | string = None | An optional salt string to use for hashing; if not provided, a new random salt is generated by the hasher. |
| hasher | string = "default" | The identifier of the hashing algorithm to use, such as 'pbkdf2_sha256' or 'argon2'. |
Returns
| Type | Description |
|---|---|
string | The hashed password string ready for database storage, or a specially formatted unusable password string if the input password was None. |