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

# HMACWith

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

## HMACWith(secret: Binary, content: Binary, @Since(version = "2.2.0") algorithm: String = "HmacSHA1"): 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 binary value) used when encrypting the <code>content</code>.</p></td></tr><tr><td><p><code>content</code></p></td><td><p>The binary input 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" }
```
