Using command line, I know that I can encrypt a directory with the following command:
zip -er Directory.zip /path/to/directory
However, this does not encrypt the filenames themselves. If someone runs:
unzip Directory.zip
and repeatedly enters a wrong password, the unzip command will loop through all of the contained filenames until the correct password is entered. Sample output:
unzip Directory.zip
Archive: Directory.zip
creating: Directory/
[Directory.zip] Directory/sensitive-file-name-1 password:
password incorrect--reenter:
password incorrect--reenter:
skipping: Directory/sensitive-file-name-1 incorrect password
[Directory.zip] Directory/sensitive-file-name-2 password:
password incorrect--reenter:
password incorrect--reenter:
skipping: Directory/sensitive-file-name-2 incorrect password
[Directory.zip] Directory/sensitive-file-name-3 password:
password incorrect--reenter:
password incorrect--reenter:
skipping: Directory/sensitive-file-name-3 incorrect password
and so on.
Using command line, is there a way to zip a directory with encryption while also encrypting or hiding the filenames themselves?
Thank you.
In a zip file, only file contents is encrypted. File metadata, including file names, is not encrypted. That's a limitation of the file format: each entry is compressed separately, and if encrypted, encrypted separately.
You can use 7-zip instead. It supports metadata encryption (-mhe=on
with the Linux command line implementation).
7z a -p -mhe=on Directory.7z /path/to/directory
There are 7zip implementations for all major operating systems and most minor ones but that might require installing extra software (IIRC Windows can unzip encrypted zip files off the box these days). If requiring 7z for decryption is a problem, you can rely on zip only by first using it to pack the directory in a single file, and then encrypting that file. If you do that, turn off compression of individual files and instruct the outer zip to compress the zip file, you'll get a better compression ratio overall.
zip -0 -r Directory.zip /path/to/directory
zip -e -n : encrypted.zip Directory.zip
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments