How to zip directory with encryption for file names?

Leo Galleguillos

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.

Gilles 'SO- stop being evil'

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How strong is the encryption of a zip file in Linux Mint

From Dev

How to zip a file to a certain directory

From Dev

How In geb download zip file into the current directory?

From Dev

How to delete the contents of the zip file but not the directory

From Dev

How to add the contents of a directory to a zip file?

From Dev

How to build a list of file names in a local directory?

From Dev

find: ‘zip’: No such file or directory

From Dev

How to Write a File to the Root Directory of a Zip File in Python

From Dev

Swapping file and directory names

From Dev

Directory/file names confusion

From Dev

How to save to txt file current directory + file names

From Dev

How to get the zip file's directory structure in PHP?

From Dev

How to extract file from zip without maintaining directory structure in Python?

From Dev

java - How to unzip all the files in a specific directory of a zip file?

From Dev

How to get the zip file's directory structure in PHP?

From Dev

how to create and download zip file without path directory

From Dev

How can I make a zip file of a directory except specific folder of it?

From Dev

How to find a .zip file in the current directory using Groovy?

From Dev

How can I obtain all of the file names in a directory?

From Dev

How to scan directory and save only image file names to array with php?

From Dev

How to list only the file names and not its attributes in a directory( in Linux)?

From Dev

PYTHON - How to change one character in many file names within a directory

From Dev

How to find file/directory names that are the same, but with different capitalization/case?

From Dev

How do I list file names on a server in a directory?

From Dev

How to list only the file names of the same type in the directory?

From Dev

How to get directory and file names while looping in shell script

From Dev

How can I recursively replace a string in file and directory names?

From Dev

How to check that the audio files in a directory match the file names stored in a database

From Dev

How to remove `_` from all file-names in a directory

Related Related

  1. 1

    How strong is the encryption of a zip file in Linux Mint

  2. 2

    How to zip a file to a certain directory

  3. 3

    How In geb download zip file into the current directory?

  4. 4

    How to delete the contents of the zip file but not the directory

  5. 5

    How to add the contents of a directory to a zip file?

  6. 6

    How to build a list of file names in a local directory?

  7. 7

    find: ‘zip’: No such file or directory

  8. 8

    How to Write a File to the Root Directory of a Zip File in Python

  9. 9

    Swapping file and directory names

  10. 10

    Directory/file names confusion

  11. 11

    How to save to txt file current directory + file names

  12. 12

    How to get the zip file's directory structure in PHP?

  13. 13

    How to extract file from zip without maintaining directory structure in Python?

  14. 14

    java - How to unzip all the files in a specific directory of a zip file?

  15. 15

    How to get the zip file's directory structure in PHP?

  16. 16

    how to create and download zip file without path directory

  17. 17

    How can I make a zip file of a directory except specific folder of it?

  18. 18

    How to find a .zip file in the current directory using Groovy?

  19. 19

    How can I obtain all of the file names in a directory?

  20. 20

    How to scan directory and save only image file names to array with php?

  21. 21

    How to list only the file names and not its attributes in a directory( in Linux)?

  22. 22

    PYTHON - How to change one character in many file names within a directory

  23. 23

    How to find file/directory names that are the same, but with different capitalization/case?

  24. 24

    How do I list file names on a server in a directory?

  25. 25

    How to list only the file names of the same type in the directory?

  26. 26

    How to get directory and file names while looping in shell script

  27. 27

    How can I recursively replace a string in file and directory names?

  28. 28

    How to check that the audio files in a directory match the file names stored in a database

  29. 29

    How to remove `_` from all file-names in a directory

HotTag

Archive