DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Using OKTA as Client Provider in Mulesoft
  • Importance Of Anypoint Dedicated Load Balancer in MuleSoft Ecosystem
  • Adding Graph Retrieval to a RAG Pipeline With Python
  • Debugging and Performance Tuning in Pega Using PAL, Tracer, and Clipboard

Trending

  • Vision-Language Models in 2026: From Research Breakthroughs to Cloud-Native Production Systems
  • PWA on iOS, Part 2: HTTPS, Manifest and Service Worker
  • How You Clear Your HTML5 Canvas Matters
  • Share Delta Lake Tables Between Databricks and Snowflake

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Implementing Dataweave Crypto With Mulesoft

Implementing Dataweave Crypto With Mulesoft

MuleSoft provides various functions to encrypt the fields within Dataweave transformation and it can be achieved using various algorithms like MD5, SHA1, etc.

By 
Jitendra Bafna
·
Sep. 03, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
15.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

MuleSoft provides various functions to encrypt the fields within Dataweave transformation and it can be achieved using various algorithms like MD5, SHA1, etc.

To use Crypto in the Datawave, one must import Crypto by using import dw::Crypto

HMACBinary

HMACBinary function will compute the HMAC hash with a Cryptographic Secret key on input data.

Parameter Description
secret Cryptographic key in binary format for encryption.
content Input Data or content in Binary format.
algorithm Hashing Algorithm. By default, HmacSHA1 is used.

Example

Input

JSON
x
 
1
%dw 2.0
2
import dw::Crypto
3
output application/json
4
---
5
{
6
    HMACBinary: Crypto::HMACBinary("632423477" as Binary,"Test123456" as Binary,"HmacSha256")
7
}


Output

Plain Text
 




xxxxxxxxxx
1


 
1
{
2
  "HMACBinary": "\u0002\u0014=\ufffdg\u0017\ufffd\u001a\u0006M\u0007\ufffd%\ufffd\ufffdʝ%\ufffdt\ufffd\ufffd\ufffd\u001d\ufffds\ufffd\ufffd\u000bž)"
3
}



HMACWith

HMACWith function will compute the HMAC hash with a Cryptographic Secret key on input data and transform the message into lowercase and hexadecimal string.

Parameter Description
secret Cryptographic  key in binary format for encryption.
content Input Data or content in Binary format.
algorithm Hashing Algorithm. By default HmacSHA1 is used.

Example

Input

JSON
 




x


 
1
%dw 2.0
2
import dw::Crypto
3
output application/json
4
---
5
{
6
    HMACWith: Crypto::HMACWith("632423477" as Binary,"Test123456" as Binary,"HmacSha512")
7
}



Output

Plain Text
 




xxxxxxxxxx
1


 
1
{
2
  "HMACWith": "e4a249fd0f737e0c455d1f250e94312d33f839a5a22f4cb66abeca3a93ff5d4039eb0e685490fc3a3b34bab371f9e255f00f7ac533b8d5175e4bd0cd6a3ad43b"
3
}



MD5

MD5 function will compute the MD5 hash and transform the binary message into lowercase and hexadecimal string.

Parameter Description
content Input Data or content in Binary format.

Example

Input

JSON
 




xxxxxxxxxx
1


 
1
%dw 2.0
2
import dw::Crypto
3
output application/json
4
---
5
{
6
    MD5: Crypto::MD5("632423477" as Binary)
7
}



Output

Plain Text
 




xxxxxxxxxx
1


 
1
{
2
  "MD5": "de1c3e94be10bd302f8728cef823970c"
3
}



SHA1

SHA1 function will compute the SHA1 hash and transform the message into lowercase and hexadecimal string.

Parameter Description
content Input Data or content in Binary format.

Example

Input

JSON
 




xxxxxxxxxx
1


 
1
%dw 2.0
2
import dw::Crypto
3
output application/json
4
---
5
{
6
    SHA1: Crypto::SHA1("632423477" as Binary)
7
}



Output

Plain Text
 




xxxxxxxxxx
1


 
1
{
2
  "SHA1": "e7224fd2a1b66f04759bfddba8c244d52d64675a"
3
}



HashWith

HashWith function will compute hash depending on the algorithm provided. 

Parameter Description
content Input Data or content in Binary format.
algorithm Supported algorithms are SHA1, SHA256, SHA384, SHA512, MD2, MD5 etc.

Example

Input

JSON
 




xxxxxxxxxx
1


 
1
%dw 2.0
2
import dw::Crypto
3
output application/json
4
---
5
{
6
    HashWith: Crypto::hashWith("632423477" as Binary,"MD2")
7
}



Output

JSON
 




xxxxxxxxxx
1


 
1
{
2
  "HashWith": ",s\ufffds\u0013\ufffd\ufffd\ufffd\ufffd\ufffd1*`gc\ufffd"
3
}


Now, you know that how we can implement the Crypto module in dataweave transformation.

Plain text MuleSoft Algorithm

Opinions expressed by DZone contributors are their own.

Related

  • Using OKTA as Client Provider in Mulesoft
  • Importance Of Anypoint Dedicated Load Balancer in MuleSoft Ecosystem
  • Adding Graph Retrieval to a RAG Pipeline With Python
  • Debugging and Performance Tuning in Pega Using PAL, Tracer, and Clipboard

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook