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

# hashWith

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

## hashWith(Binary, String): 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 content to hash.</p></td></tr><tr><td><p><code>algorithm</code></p></td><td><p>The name of the algorithm to use to calculate the hash value of <code>content</code>. This value is a <code>String</code>. 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" }
```
