top of page

See other Articles

Protect Your Files: How to Decrypt Files in MuleSoft in 3 Steps

Oct 27

2 min read

1

19

Introduction


In today's data-driven environment, knowing how to decrypt files is essential for accessing sensitive information securely.


This blog will guide you through a 3-step process to decrypt files in MuleSoft, ensuring secure access to your sensitive data.


Prerequisites




Decrypt File in Anypoint Studio


Step 1: Add Cryptography Module and PGP Keys


  1. Create or open a Mule project in Anypoint Studio 7.x.


  2. Log in with your Anypoint Platform credentials (if you aren’t already logged in).


  3. In the Mule Palette, add the "Cryptography Module - Mule 4" from Exchange as a dependency.

  4. Add the PGP public key and private key files in the src/main/resources of your Mule project.

    • public-key.asc (optional)

    • private-key.asc




Step 2: Configure Cryptography Module for Decryption


  1. In the Global Elements tab, click create and search for "Crypto PGP".


  2. In the Crypto PGP Configuration window, set the following:

    • Private Keyring: Select or enter the path to your private-key.asc file.

    • Click the "+" button to add a key configuration and set the following values:

      • Key ID: Set a value, such as "private-key".

      • Fingerprint: Enter the fingerprint of the generated PGP key.

      • Passphrase: Provide the passphrase associated with your private key.



Step 3: Create Decryption Mule Flow


  1. Read any file using the Read operation of File Connector module.

    • Populate "File Path" with the directory path and filename for your file. In this example, we will use 'sample-file-encrypted.gpg'.


  2. Decrypt the content using the Pgp decrypt operation of Crypto Connector module.

    • Add module configuration using the global configuration created in configuration Step #2.


  3. Write the decrypted data using Write operation of File Connector module.

    • Populate "Path" with the directory path and file name for your decrypted file. In this example, we will name the decrypted file as 'sample-file-decrypted.txt'.

  4. Transform the final JSON payload for clarity and readability. (optional)


  5. Run in Postman or any API client.


  6. View decrypted file in your file directory.


Conclusion


Decrypting files in MuleSoft is essential for securely accessing sensitive data. By following the 3-steps outlined in this blow, you can protect your information while ensuring authorized access.



Github Repository


1
2
bottom of page