commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: compress - 3 questions about encryption
Date Fri, 17 Sep 2010 12:46:59 GMT
On 2010-09-17, Chris Bamford wrote:

> I am developing Java code to handle archives using commons compress
> and am currently focusing on ZIP files.  I understand that ZIPs can be
> encrypted in two ways:

>    (a) the contained entries can be plain text or encrypted
>    (b) the whole ZIP itself can be encrypted

> QUESTION 1:  Is this correct?

More or less, yes.  (a) is even a bit more complex since there are
different ways an entry can be encrypted (there is an old-style
encryption and a more modern variant that signals the algorithm used).

In either case, Commons Compress doesn't support encryption of ZIPs in
any way.

> So far I only know how to handle (a), by using this method:

>     public boolean checkZipEntryIsEncrypted(ZipArchiveEntry entry) {
>         boolean encrypted = false;

>         // Check if zip file is encrypted
>         if (zfile != null) {
>             if (! zfile.canReadEntryData(entry)) {
>                 encrypted = true;
>             }
>         }

>         return encrypted;
>     }

> QUESTION 2: is this the right way to detect encrypted entries?

encryption is one of the reasons canReadEntryData may return false,
another reason could be an unsupported compression algorithm.

> QUESTION 3: what is the right way to detect that the ZIP itself is
> encrypted?

There isn't any built into Commons Compress ATM.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message