简体   繁体   中英

How to unzip a password-protected archive created by Linux, using Java

I am working on an Android project recently and met an issue. I send a request to webservice and got a zip file with password protection. The zip file is create using the Linux command

zip -P 123123123123123123 test.zip test.txt

I want to unzip it with Java. Because there is no standard API support so I need a third library.

  1. I have tried winzipaes , but it prompts that my zip file is not in the AES-256 format.
  2. I cannot use sevenzipjbinding , it's too large.

Do you have any suggestion about this? Do you know what algorithm Linux used to encrypt the zip file?

Finally, I done with zip4j.

  1. Download zip4j-1.3.1 and import it to project.

  2. Sample Code:

     ZipFile zipFile = new ZipFile(YourZipFile); if(zipFile.isEncrypted()){ zipFile.setPassword(Password); } zipFile.extractAll(Destination); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM