---
schema_version: "1"
id: 94a84d5f4b66bfc89985a53c1bab65af8efcd3fc7a53baf29bc03c00091f9469
title: hashWith
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-crypto-functions-hashwith.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-crypto-functions-hashwith
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 40ca1994d765bee1abf1091c7d7ce4331e9f7edef6b662bac72d77c79f10b0e6
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# hashWith

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

## hashWith(content: Binary, algorithm: String = "SHA-1"): Binary

Computes the hash value of binary content using a specified algorithm.

The first argument specifies the binary content to use to calculate the hash value, and the second
argument specifies the hashing algorithm to use. The second argument must be any of the accepted
Algorithm names:

<table><colgroup><col> <col></colgroup><thead><tr><th>Algorithm names</th><th>Description</th></tr></thead><tbody><tr><td><p><code>MD2</code></p></td><td><p>The MD2 message digest algorithm as defined in <a href="https://www.ietf.org/rfc/rfc1319.txt">RFC 1319</a>.</p></td></tr><tr><td><p><code>MD5</code></p></td><td><p>The MD5 message digest algorithm as defined in <a href="https://www.ietf.org/rfc/rfc1321.txt">RFC 1321</a>.</p></td></tr><tr><td><p><code>SHA-1</code>, <code>SHA-256</code>, <code>SHA-384</code>, <code>SHA-512</code></p></td><td><p>Hash algorithms defined in the <a href="https://csrc.nist.gov/publications/fips">FIPS PUB 180-2</a>. SHA-256 is a 256-bit hash function intended to provide 128 bits of security against collision attacks, while SHA-512 is a 512-bit hash function intended to provide 256 bits of security. A 384-bit hash may be obtained by truncating the SHA-512 output.</p></td></tr></tbody></table>

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>content</code></p></td><td><p>The binary input value to hash.</p></td></tr><tr><td><p><code>algorithm</code></p></td><td><p>The name of the algorithm to use for calculating the hash value of <code>content</code>. This value is a string. Defaults to <code>SHA-1</code>.</p></td></tr></tbody></table>

### Example

This example uses the MD2 algorithm to encrypt a binary value.

#### Source

```DataWeave
%dw 2.0
import dw::Crypto
output application/json
---
{ "md2" : Crypto::hashWith("hello" as Binary, "MD2") }
```

#### Output

```JSON
{ "md2": "\ufffd\u0004ls\ufffd\u00031\ufffdh\ufffd}8\u0004\ufffd\u0006U" }
```
