                  ('salt', 'value'),
                  {'secret': 'x' * hashlib.sha1().block_size},
                  'bd3749347b412b1b0a9ea65220e55767ac8e96b0',
              ),
          ]
          for args, kwargs, digest in tests:
              with self.subTest(args=args, kwargs=kwargs):
                  self.assertEqual(salted_hmac(*args, **kwargs).hexdigest(), digest)
  
 
</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'): </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 class TestUtilsCryptoMisc(unittest.TestCase):
 </s> add class TestUtilsCryptoMisc(SimpleTestCase): </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)
            (
                ('salt', 'value'),
                {'algorithm': 'sha256'},
                'ee0bf789e4e009371a5372c90f73fcf17695a8439c9108b0480f14e347b3f9ec',
            ),
            (
                ('salt', 'value'),
                {
                    'algorithm': 'blake2b',
                    'secret': 'x' * hashlib.blake2b().block_size,
                },
                'fc6b9800a584d40732a07fa33fb69c35211269441823bca431a143853c32f'
                'e836cf19ab881689528ede647dac412170cd5d3407b44c6d0f44630690c54'
                'ad3d58',
            ),
                  ('salt', 'value'),
                  {'secret': 'x' * hashlib.sha1().block_size},
                  'bd3749347b412b1b0a9ea65220e55767ac8e96b0',
              ),
            (
                ('salt', 'value'),
                {'algorithm': 'sha256'},
                'ee0bf789e4e009371a5372c90f73fcf17695a8439c9108b0480f14e347b3f9ec',
            ),
            (
                ('salt', 'value'),
                {
                    'algorithm': 'blake2b',
                    'secret': 'x' * hashlib.blake2b().block_size,
                },
                'fc6b9800a584d40732a07fa33fb69c35211269441823bca431a143853c32f'
                'e836cf19ab881689528ede647dac412170cd5d3407b44c6d0f44630690c54'
                'ad3d58',
            ),
          ]
          for args, kwargs, digest in tests:
              with self.subTest(args=args, kwargs=kwargs):
                  self.assertEqual(salted_hmac(*args, **kwargs).hexdigest(), digest)
  
keep keep keep add keep keep keep keep keep
 Refs #27468 -- Added algorithm parameter to django.utils.crypto.salted_hmac(). 
tests/utils_tests/test_crypto.py