Computes the hash-based message authentication code (HMAC) for data given a secret key and hashing algorithm.
Arguments
| Arguments | |
|---|---|
| key | 
 The secret key to use when computing HMAC hash. | 
| data | 
 The input to compute HMAC for. | 
| algorithm | 
 The hashing algorithm to use when computing HMAC hash. Supported algorithms:  | 
Returns
The computed HMAC hash in bytes.
Raised exceptions
| Exceptions | |
|---|---|
| TypeError | If keyanddataare not in bytes, or ifalgorithmis not a string. | 
| ValueError | If the provided hashing algorithm is not supported. | 
Examples
For more information, see Returning bytes.
# Compute HMAC SHA-256 hash for message (bytes) using a secret key (bytes) - assignStep: assign: - keyBytes: ${text.encode("key", "UTF-8")} - dataBytes: ${text.encode("Hello World", "UTF-8")} - algorithmName: "SHA256" # Compute HMAC SHA-256 hash for data in bytes - hmac: ${hash.compute_hmac(keyBytes, dataBytes, algorithmName)} - returnStep: # Return HMAC encoded to Base64 string: "QidPcoCDkuWLV9co1+PA5RY+rwfRZdwDEF9iq74afRE=" return: ${base64.encode(hmac)}