# Hash.hmac256

Calculates the [HMAC-SHA256](https://en.wikipedia.org/wiki/HMAC) of a [`Bytes.Bytes`](/api/Bytes/types#bytes) or [`Hex.Hex`](/api/Hex/types#hex) value.

This function is a re-export of `hmac` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.

## Imports

:::code-group
```ts [Named]
import { Hash } from 'ox'
```

```ts [Entrypoint]
import * as Hash from 'ox/Hash'
```
:::

## Examples

```ts twoslash
import { Hash, Hex } from 'ox'

Hash.hmac256(Hex.fromString('key'), '0xdeadbeef')
// @log: '0x...'
```

### Configure Return Type

```ts twoslash
import { Hash, Hex } from 'ox'

Hash.hmac256(Hex.fromString('key'), '0xdeadbeef', {
  as: 'Bytes'
})
// @log: Uint8Array [...]
```

## Definition

```ts
function hmac256<value, as>(
  key: Hex.Hex | Bytes.Bytes,
  value: value | Hex.Hex | Bytes.Bytes,
  options?: hmac256.Options<as>,
): hmac256.ReturnType<as>
```

**Source:** [src/core/Hash.ts](https://github.com/wevm/ox/blob/main/src/core/Hash.ts#L270)

## Parameters

### key

* **Type:** `Hex.Hex | Bytes.Bytes`

[`Bytes.Bytes`](/api/Bytes/types#bytes) or [`Hex.Hex`](/api/Hex/types#hex) key.

### value

* **Type:** `value | Hex.Hex | Bytes.Bytes`

[`Bytes.Bytes`](/api/Bytes/types#bytes) or [`Hex.Hex`](/api/Hex/types#hex) value.

### options

* **Type:** `hmac256.Options<as>`
* **Optional**

Options.

#### options.as

* **Type:** `"Bytes" | "Hex" | as`
* **Optional**

The return type.

## Return Type

HMAC-SHA256 hash.

`hmac256.ReturnType<as>`
