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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • A Complete Guide on How to Convert InputStream to String In Java
  • Adding Two Hours in DataWeave: Mule 4
  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • How to Convert Files to Thumbnail Images in Java

Trending

  • Detecting Advanced Persistent Threats Using Behavioral Analytics and Log Correlation
  • Introduction to Retrieval Augmented Generation (RAG)
  • Building Production-Grade GenAI on GCP with Vertex AI Agent Builder
  • Leveraging Apache Flink Dashboard for Real-Time Data Processing in AWS Apache Flink Managed Service
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Cryptography Module in Mule 4

Cryptography Module in Mule 4

By 
Pooja Bhosle user avatar
Pooja Bhosle
·
May. 18, 20 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
8.7K Views

Join the DZone community and get the full member experience.

Join For Free

Steps to Use JCE Encrypt and JCE Decrypt Connectors

  1. Check if Crypto module is available in Mule Palette. If not, download it from exchange.
  2. Then, search for JCE in the Mule palette. The Crypto module should be visible now.

Mule pallette
3. To use Jce encrypt and decrypt connector, we need a keystore.

  • Generate a keystore using following command:  

keytool.exe -genseckey -alias jksvalue -keyalg Blowfish -keystore encKeystore.jceks -keysize 128 -storeType JCEKS

Alias name : jksvalue 

Algorithm used : Blowfish

Keystore file name : encKeystore

Keystore file type : jceks

 Using JCE encrypt

Keep the keystore and key passwords. These passwords need to be use in JCE configuration. 

  • Store the generated encKeystore.jceks file in resource folder of mule project.
  • Take Jce encrypt connector from the Mule palette and do the module configuration as shown below : 

Module configuration


Module configuration

We are using a symmetric key (same key for encryption and decryption). Add the symmetric key details using the + button in the above image. 

Adding symmetric key details


Configuring JCE key

Do the remaining configuration just shown in the above image. Note that the algorithm should be the same, which we used for creating the Keystore and the Key id in the above two images should be identical. 

Check the advanced section. 

Checking Keystore and key Id

The output of this component below is the encrypted value : 

Encrypted value

The encrypted value has a few characters, which cannot be shared or we cannot type it. Here comes the encoding part to convert the encrypted string to Base64 format.  

Encoding can be done using the below transformation:

Payload to Base 64

The output of encoding is below: 

Encoding below

In the same way, we have to first decode the payload and then decrypt it:

Encoding payload

Decrypting payload

Java Cryptography Extension Connector (mathematics) Algorithm Base64 Strings Convert (command) Command (computing) Data Types

Opinions expressed by DZone contributors are their own.

Related

  • A Complete Guide on How to Convert InputStream to String In Java
  • Adding Two Hours in DataWeave: Mule 4
  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • How to Convert Files to Thumbnail Images in Java

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • 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