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 just tried to encrypt a folder with 7-Zip by a command line, choosing a password, but when double-clicking on the ZIP file, it shows me the files list without asking any password.

Is there a way to truly encrypt a folder from the command line?

share|improve this question
up vote 23 down vote accepted

The ZIP format doesn't allow for encrypting file lists. This means that file lists are viewable by anyone.

Only the contents of the files is encrypted, which means that no one can read the file without your password.

Due to this, 7-Zip only asks for your password before unzipping.

If you need a format that encrypts the file list, use 7Z and make sure you check "Encrypt File Names".

For the more technical minded, the ZIP specification doesn't allow for encryption of the Central Directory.

share|improve this answer

You will be prompted for a password when you try to extract the files. To simply view the contents of the archive does not require a password.

If you would like to obfuscate the contents of the archive, compress the directory into an archive, and then compress that archive with a password. Thus, you will have to extract the archive with a password, to pull out the archived (and obfuscated) contents.

share|improve this answer
Don't waste your CPU cycles on compression the second time round, if you can avoid it, though. – Phoshi Nov 13 '09 at 22:58
True enough. It's certainly easy enough to select Store for the compression mechanism on the second iteration. I have Fastest set as my default, and 7-Zip is ridiculously fast anyway. :) – JMD Nov 13 '09 at 23:26

A generalized solution that works for all zip programs (WINzip, 7-Zip, MacZip, etc.) is to simply zip it twice making sure the second time (or both) have password protected encryption.

See: Filenames display without entering the password when an encrypted Zip file is opened

share|improve this answer

You can use GNU Tar to turn the directory into a single file, which you can then compress as a regular file with 7z. Anyone viewing the archive will just see the tar file.

share|improve this answer
Hi Good suggestion – asksuperuser Nov 14 '09 at 23:52
You don't need another tool; 7-Zip can also make a tar file. For instance, after choosing "Add to archive", chose "tar" for option "Archive format". There must be a similar option on the command line. – Peter Mortensen Jun 11 at 20:01

I found your answer in Do encrypted compression containers like ZIP and 7-Zip compress or encrypt first?.

The command line switch to encrypt the headers (i.e. the file names) in 7-Zip is:

share|improve this answer

Double clicking will show you the files. Now try to extract one... as I recall, that is when you'll get the password prompt.

share|improve this answer

In case you're using Total Commander with the 7-Zip Plugin, press ALT + F5 (or Files -> Pack...) to compress files or folders, click Configure and check the box Encrypt File Headers and Names.

Other than that, Andrew Moore's answer is correct.

share|improve this answer
Thanks for the tips – asksuperuser Nov 14 '09 at 23:50

You must log in to answer this question.