Search code examples
encryptionzipmulesoftmule4cloudhub

How to compress a payload with a password in Mule 4?


I need to zip a payload (a dataweave script outputting CSV) with a password using Mule 4 with encryption AES256.

I've checked the Compression Module of Mule 4 and it doesnt support passwords, I've tried using it in combination of the Cryptography Module but it either ends up encrypting the CSV in the zip, or encrypting the zip.

I need the solution to be able to run in Cloudhub too.

Any ideas?

Cheers, Steve


Solution

  • Just encrypting the files will not work because the Zip format expects an encryption header for encrypted files.

    Mule Compression module uses the Apache Commons Compress library to implement Zip files, which doesn't currently support Zip encrypted files.

    You can try to either implement your own module or extend the existing Compression module to support encryption. You can also just call a Java class to do it, but it will not be as reusable in Mule applications.

    One library that can be used to implement encrypted Zip files is Zip4j but there might be others. Since it is a Java implementation it should work in any platform.