Compute a keyed hash (HMAC) of a message, the same construction used to sign webhooks, API requests and many token formats. The calculation runs locally with crypto.subtle.

Both the key and the message can be given as UTF-8 text, hex or Base64, which matters when a provider hands you a Base64-encoded signing secret: decoding it first produces a different HMAC than using the Base64 string as text. Output can be hex (lower or upper case), Base64 or Base64URL to match whatever the receiving side compares against.

When verifying a webhook, make sure you hash the exact raw request body. Re-serialised JSON with different whitespace or key order produces a completely different signature. Empty keys are rejected because browsers do not allow zero-length HMAC keys.