Reading Password-Protected ZIP Files in Java
I have recently dealt with a requirement to extract a password protected zip file that was generated by an external product with CAPI (Microsoft Cryptography API). It was one of these features I thought will take me no time to implement. Anyway, to my surprise, neither JDK supports password-protected ZIP files, nor I was able to find a suitable Java open source library I could use for that purpose. There are several alternatives for solving this issue but each of them has other disadvantages. Finally I found also an open source that supports the most common zip formats and this is the solution I used (the details in the last bullet):
- First we have the known 7-Zip software. This is an open source that gives the ability to unzip or decompress a password protected zip file, you have to use “sevenzipjbind”. It is available in sourceforge.net site. You can download the .jar files from the following link: sourceforge.net/projects/sevenzipjbind/files. This API helps to extract all the files and folders from password protected zip file created by any zip utility tool. You have to download the following .jar files from the above URL sevenzipjbinding.jar and sevenzipjbinding-AllPlatforms.jar for linux platforms. The minus with this framework is it contains JNI library, so if you would like to have application without native code it is not your solution.
- There are also more than one licensing APIs, that gives very simple APIs to unzip protected zip files. Here is one link for such library: www.chilkatsoft.com/java-zip.asp. There are two problem with this: one that it is not freeware, and also frequently uses native code.
- Finally after devoting pretty much googling time I found a new open-source library to handle zip files (a single package was released on the end of 2010). It supports the two most used zip encryption methods, and matched exactly to my requirements and hope for yours too. The link for the project is: www.lingala.net/zip4j. Note it is released under Apache License, Version 2.0, and doesn't contain ant kind of native code.
For responses you are always invited to email: email@example.com
We will contact you as soon as possible.