          secret = settings.SECRET_KEY
  
      key_salt = force_bytes(key_salt)
      secret = force_bytes(secret)
  
      # We need to generate a derived key from our base key.  We can do this by
      # passing the key_salt and our base key through a pseudo-random function and
      # SHA1 works nicely.
      key = hashlib.sha1(key_salt + secret).digest()
      # If len(key_salt + secret) > block size of the hash algorithm, the above
 
</s> remove     # passing the key_salt and our base key through a pseudo-random function and
    # SHA1 works nicely.
    key = hashlib.sha1(key_salt + secret).digest()
 </s> add     # passing the key_salt and our base key through a pseudo-random function.
    key = hasher(key_salt + secret).digest() </s> remove     return hmac.new(key, msg=force_bytes(value), digestmod=hashlib.sha1)
 </s> add     return hmac.new(key, msg=force_bytes(value), digestmod=hasher) </s> remove     Return the HMAC-SHA1 of 'value', using a key generated from key_salt and a
    secret (which defaults to settings.SECRET_KEY).
 </s> add     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.new() can be passed. </s> remove def salted_hmac(key_salt, value, secret=None):
 </s> add class InvalidAlgorithm(ValueError):
    """Algorithm is not supported by hashlib."""
    pass


def salted_hmac(key_salt, value, secret=None, *, algorithm='sha1'):
    try:
        hasher = getattr(hashlib, algorithm)
    except AttributeError as e:
        raise InvalidAlgorithm(
            '%r is not an algorithm accepted by the hashlib module.'
            % algorithm
        ) from e
          secret = settings.SECRET_KEY
  
      key_salt = force_bytes(key_salt)
      secret = force_bytes(secret)
    try:
        hasher = getattr(hashlib, algorithm)
    except AttributeError as e:
        raise InvalidAlgorithm(
            '%r is not an algorithm accepted by the hashlib module.'
            % algorithm
        ) from e
      # We need to generate a derived key from our base key.  We can do this by
      # passing the key_salt and our base key through a pseudo-random function and
      # SHA1 works nicely.
      key = hashlib.sha1(key_salt + secret).digest()
      # If len(key_salt + secret) > block size of the hash algorithm, the above
keep keep keep keep replace keep keep keep keep keep
 Refs #27468 -- Added algorithm parameter to django.utils.crypto.salted_hmac(). 
django/utils/crypto.py