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

Function hmac_sha256_long_key

rust/stringzilla.rs:3924–3935  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3922
3923 #[test]
3924 fn hmac_sha256_long_key() {
3925 // Test with key longer than block size (> 64 bytes)
3926 let key = b"this is a very long key that exceeds the SHA256 block size of 64 bytes for testing purposes";
3927 let message = b"message";
3928 let mac = sz::hmac_sha256(key, message);
3929 // Expected value computed with Python: hmac.new(key, message, hashlib.sha256).digest()
3930 let expected = [
3931 0xd1, 0x3f, 0xdb, 0x7b, 0xe0, 0x9a, 0x9e, 0x07, 0x04, 0xc6, 0x5b, 0xd7, 0x85, 0xa6, 0x33, 0xbb, 0xc0, 0xee,
3932 0x2b, 0x99, 0xef, 0xd6, 0x32, 0x2c, 0xa9, 0x4c, 0xd3, 0x2c, 0x1e, 0x45, 0x09, 0xfd,
3933 ];
3934 assert_eq!(mac, expected);
3935 }
3936
3937 #[test]
3938 #[should_panic]

Callers

nothing calls this directly

Calls 1

hmac_sha256Function · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…