Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for the bit flags to detect the file is password-protected, not a regular .zip or .rar.

share|improve this question
What OS/environment/language are you on? Do you want to be able to figure this out from the shell, programmatically, etc.? – Matthew Flaschen Jul 30 '10 at 21:09

You can use zipinfo and unrar to test whether a ZIP file is encrypted. E.g.:

zipinfo -v |grep 'file security status:\s*encrypted'
unrar v -p- file.rar 2>&1|grep 'Encrypted file'
share|improve this answer

You can read about the header structure of rar here

And about the zip header structure here

It helps to download the source code of opensource unpackers to read some code examples.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .