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?
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.
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.
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
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:
-mhe=on
e.g. 7z a -pPassword123 -mhe=on archive.7z file.txt
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.
Double clicking will show you the files. Now try to extract one... as I recall, that is when you'll get the password prompt.
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.