---
title: "crypt.hmac"
description: "Computes HMAC-SHA256 and returns a Base64 digest."
---

```lua
crypt.hmac(key: string, data: string, algorithm: string? = "sha256"): string
```

---

## Aliases

None.

---

## Arguments

<ParamField body="key" type="string" required>
  The raw HMAC key bytes. The key is not implicitly Base64-decoded.
</ParamField>

<ParamField body="data" type="string" required>
  The input bytes as a binary-safe Luau string.
</ParamField>

<ParamField body="algorithm" type="string" default={"\"sha256\""}>
  The digest algorithm name. See the supported values under Returns.
</ParamField>

---

## Returns

<ResponseField name="digest" type="string">
  The Base64-encoded HMAC-SHA256 digest.
</ResponseField>

Only sha256 is supported, case-insensitive. Key comes first and is raw bytes, not implicitly Base64-decoded.

---

## Example

```lua
print(crypt.hmac("example-key", "hello"))
```
