> ## Documentation Index
> Fetch the complete documentation index at: https://docsuncv2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# crypt.hmac

Computes a Hash-based Message Authentication Code (HMAC) for the given data payload using a key and algorithm.

```luau theme={null}
crypt.hmac(data: string, key: string, algorithm: string): string
```

## Parameters

| Parameter   | Type     | Description                                     |
| ----------- | -------- | ----------------------------------------------- |
| `data`      | `string` | The data message payload to sign.               |
| `key`       | `string` | The secret key.                                 |
| `algorithm` | `string` | The hashing algorithm to use (e.g. `'sha256'`). |

## Returns

`string` - The resulting HMAC signature as a hex string.

## Example

<CodeGroup>
  ```luau Example 1 theme={null}
  local signature = crypt.hmac("payload", "secret_key", "sha256")
  print("Signature: ", signature)
  ```

  ```luau Example 2 theme={null}
  local hmacVal = crypt.hmac("my-data", "key", "md5")
  ```
</CodeGroup>

<Tip>
  Used to verify both data integrity and authenticity of communication payloads.
</Tip>
