views:

39

answers:

1

Hello friends,

I'm using lib ZipArchive to unzip file on iPhone, it works pretty well, however I met a issue about checking if a zip file is protected by password.

I'm wondering if there's a function to check whether a zip file is protected by password before unzipping, but I didn't get lucky to find an api for that. So does anyone who know how to check it in Objective-C/iPhone or any API in ZipArchive I can use.

Any help would be greatly appreciated.

A: 

You can check central directory in archive, and see if encryption bit is set there. However, you will need to read some documentation regarding zip file format.

Nickolay O.
Thank you, Nick. I read the zip format document on wikipedia, "General purpose bit flag" of ZIP central directory file header is used to indicate if a file is protected by password.I used a hex editor to open a encryption zip file, I found some of encryption bit has been set to 0, but some of them are set to 1; Also checked on non-encryption zip file, all of encryption bits are set to 0. I don't understand why, could you please help explain that?Thanks in advance.
Matt Chen