HMAC functions in the Crypto DuckDB extension
Function category
HMAC
1 functionKeyed message authentication codes. Use for signing API requests, verifying message integrity, or building tamper-evident audit trails — anywhere a hash needs a shared secret.
Signature
crypto_hmac(
algorithm: VARCHAR,
key: VARCHAR,
message: VARCHAR
) → BLOB
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
algorithm
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
key
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
message
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Hash-based Message Authentication Code (HMAC). Combines a secret key with a message under a specified hash algorithm — used for message integrity, API request signing, and timing-safe authentication.
1
HMAC-SHA256 over a message with a secret key
SELECT lower(to_hex(crypto_hmac('sha2-256', 'my-secret-key', 'important message')));
Output
| lower(to_hex(crypto_hmac('sha2-256', 'my-secret-key', 'important message'))) |
|---|
| 97f324adef061b4ad0abeb6be543913d7db6ba8e6e7f33cd3c4395d619b56df4 |