Skip to content

hmac

hmac<THashReturnArrayBuffer>(hash, blockSizeBytes, key, message, tagLengthBytes?): Uint8Array<THashReturnArrayBuffer>

Defined in: hmac-core.ts:21

HMAC (RFC 2104 / FIPS 198-1): a keyed-hash message authentication code built from any hash function and its compression function’s block size — both supplied explicitly by the caller (e.g. hmac(sha256Ts, 64, key, message)), matching every other block-size-parametrized primitive in crypto/hash (merkleDamgardPad) rather than a hash-algorithm registry; the caller owns algorithm specificities.

THashReturnArrayBuffer extends ArrayBufferLike

(data) => Uint8Array<THashReturnArrayBuffer>

A one-shot, synchronous hash function — the TS kernel of whichever algorithm the caller has chosen (e.g. sha256Ts), never the Web-Crypto-preferring dual kernel, since that one’s Promise-returning shape doesn’t fit HMAC’s handful of nested synchronous calls.

number

hash’s compression function’s block size — 64 for MD5/SHA-1/SHA-224/SHA-256, 128 for SHA-384/SHA-512.

Uint8Array

Uint8Array

number

Truncates the returned tag to this many bytes (RFC 2104 §5). Defaults to the full untruncated output.

Uint8Array<THashReturnArrayBuffer>