Search code examples
javazipzip4j

How to create a password-protected zip folder in Java?


It is important that the zip file should be password protected and not the files contained inside the zip. It means that when I double-click on the zip file it should ask me the password before showing the contents of the zip.

I have tried Zip4j and Winzipaes libraries but they both encrypt the content files inside the zip, not the zip itself. I have also tried several answers from Stackoverflow but to no avail. Please help.


Solution

  • As stated here by WinZip, the Zip format encrypts the files inside the archive only and not the zip itself. http://kb.winzip.com/kb/entry/147/

    However, as the article suggests, double zipping the archive will hide files inside the inner zip file. As long as you encrypt the outer archive.