Using 7-Zip to create AES-256 encrypted zip files from the command line

Sunday, March 11, 2018


The default encryption method used by 7-Zip for Zip files, and the only method supported by InfoZip, is ZipCrypto, which is generally pretty terrible. To create AES-256 encrypted archives using 7-Zip, use:

$ 7z a -tzip -mem=AES256 -p super-secret.zip super-secret.txt

To verify that it worked, use:

$ 7za l -slt super-secret.zip

Notice that all the filenames within the archive are visible; I don't think 7-Zip supports Zip header encryption. You can do it the ghetto way by simply putting a Zip inside an encrypted Zip to hide the filenames in the inner one.

Tags: | Posted at 20:50 | Comments (4)


Comments

Konrad Gaworek on Tuesday, January 28, 2020 at 04:57

Hi,
7z supports header encription:
(from manual)
-mhe=on|off
7z format only : enables or disables archive header
encryption (Default : off)

David Zhang on Tuesday, January 28, 2020 at 17:51

-mhe=on only works with 7-Zip (*.7z) archives, not Zip archives, as noted in the manual snippet you've pasted.

As far as I can tell, you can't pass -mhe=on (or anything equivalent) to 7-Zip when creating Zip archives.

Gareth on Wednesday, September 30, 2020 at 09:02

This worked for me. Thanks for the information.

Chris Clark on Sunday, February 12, 2023 at 12:15

Just wanted to say thanks to sharing! At one point I though 7z only support ZipCrypto or AES for 7z archives only.

Add a comment

Name:
Email: (optional, not displayed to public)
URL: (do not fill this in — leave blank!)

Comment: