MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / test_hmac_sha256

Function test_hmac_sha256

scripts/test_stringzilla.py:1106–1121  ·  view source on GitHub ↗
(key_length: int, message_length: int, seed_value: int)

Source from the content-addressed store, hash-verified

1104@pytest.mark.parametrize("message_length", [0, 1, 63, 64, 65, 127, 128, 1000])
1105@pytest.mark.parametrize("seed_value", SEED_VALUES)
1106def test_hmac_sha256(key_length: int, message_length: int, seed_value: int):
1107
1108 seed_random_generators(seed_value)
1109 key = get_random_string(length=key_length).encode()
1110 message = get_random_string(length=message_length).encode()
1111
1112 # Test against Python's hmac module
1113 expected = hmac.new(key, message, hashlib.sha256).digest()
1114 result = sz.hmac_sha256(key, message)
1115 assert result == expected
1116
1117 # Test with string inputs
1118 key_str = key.decode("latin1")
1119 message_str = message.decode("latin1")
1120 result_str = sz.hmac_sha256(key_str, message_str)
1121 assert result_str == expected
1122
1123
1124def test_hmac_sha256_kwargs():

Callers

nothing calls this directly

Calls 4

seed_random_generatorsFunction · 0.70
get_random_stringFunction · 0.70
digestMethod · 0.45
newMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…