Signature
String hmac_sha256_hex(String key, String data)
Parameters
key : secret key
data : message to authenticate
return value : the HMAC-SHA256 as a 64-character lowercase hex string
Computes an HMAC-SHA256 message authentication code and returns it as hex. Use it to sign tokens, cookies, and webhook payloads, then verify with crypto_equal() to avoid timing leaks.
Example
print(hmac_sha256_hex("key", "The quick brown fox jumps over the lazy dog"), "\n");
Output
f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8