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.
Removed in Django70Warning: The default algorithm will change to SHA256
in Django 7.0, so provide an explicit algorithm to silence the warning.
A different key_salt should be passed in for every application of HMAC.
def salted_hmac(
key_salt: string|bytes,
value: string|bytes,
secret: string|bytes = None,
algorithm: string = None
) - > hmac.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.
Parameters
| Name | Type | Description |
|---|---|---|
| key_salt | `string | bytes` |
| value | `string | bytes` |
| secret | `string | bytes` = None |
| algorithm | string = None | The name of the hashing algorithm to use (e.g., 'sha256'); defaults to 'sha1' with a deprecation warning. |
Returns
| Type | Description |
|---|---|
hmac.HMAC | An HMAC object containing the message authentication code for the provided value. |