Saturday 25 Mar 2023

7Zip encryption using CLI

Image copyright

When using the command-line interface (CLI) to compress with 7Zip, it may be necessary to encrypt the archive. This is easy to do with an extra switch to the command (-p).

"C:\Program Files\7-Zip\7z.exe" a E:\a-compressed-file.7z -psecretpass123 -mhe E:\important-documents\

In this example, the password is "secretpass123".

a = create an archive
p= set the password
mhe = encrypts archive headers (password required to list files within the archive)

More on 7zip encryption