---
schema_version: "1"
id: 6fa241ea6f3fca99c174bf8c47fc27b7f069970b7bb44f25b02c7d992791ed98
title: HMACWith
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-crypto-functions-hmacwith.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-crypto-functions-hmacwith
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 65004e72386ecfd8405ff49ec8dbecbbe395f5377677564d2012b70cdbfae0fa
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# HMACWith

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## HMACWith(Binary, Binary, String): String

Computes an HMAC hash (with a secret cryptographic key) on input content, then transforms the result
into a lowercase, hexadecimal string.

See also, `HMACBinary`.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>secret</code></p></td><td><p>The secret cryptographic key (a <code>Binary</code>) used when encrypting the <code>content</code>).</p></td></tr><tr><td><p><code>content</code></p></td><td><p>The input content, a <code>Binary</code> value.</p></td></tr><tr><td><p><code>algorithm</code></p></td><td><p>(<em>Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later.</em>) The hashing algorithm. By default, <code>HmacSHA1</code> is used. Other valid values are <code>HmacSHA256</code> and <code>HmacSHA512</code>.</p></td></tr></tbody></table>

### Example

This example uses HMAC with a secret value to encrypt the input content using the `HmacSHA256`
algorithm.

#### Source

```DataWeave
%dw 2.0
import dw::Crypto
output application/json
---
{ "HMACWith" : Crypto::HMACWith("secret_key" as Binary, "Some value to hash" as Binary, "HmacSHA256") }
```

#### Output

```JSON
{ "HMACWith": "b51b4fe8c4e37304605753272b5b4321f9644a9b09cb1179d7016c25041d1747" }
```
