Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

7-Zip command to create and extract a password-protected ZIP file on Windows? [closed]

On Mac/Linux to zip/unzip password protected zip files, I use: Zip:

zip -P password -r encrypted.zip folderIWantToZip 

Unzip:

unzip -P password encrypted.zip 

What are the equivalent command on Windows on the command line (assuming that 7zip has been installed)?

I have been doing research and found that it is not possible to password encrypt using the Java zip4j library. Also Windows does not have a zip command prompt like Mac/Linux

like image 498
user3254893 Avatar asked Jan 26 '15 22:01

user3254893


People also ask

How do I use 7Zip to password protect a zip file?

From the "Archive format" field, select zip. Under the "Encryption" section, enter a strong password or passphrase in the "Enter passphrase" field and again in the "Reenter passphrase" field. Ensure the "Encryption method" is AES-256. Onced finished, click OK.

How do I create a password protected zip file in Windows 7?

Microsoft Windows Vista, 7, 8, and 10 users Select the file or folder you want to encrypt. Right-click the file or folder and select Properties. On the General tab, click the Advanced button. Check the box for the "Encrypt contents to secure data" option, then click OK on both windows.

Does 7-Zip allow password protection?

7-Zip, like WinZip, creates a container called archive that holds the files to be protected. That archive can be encrypted and protected with a password. 7-Zip is a free software that creates Zip files that can be opened with WinZip or other similar programs.


2 Answers

From http://www.dotnetperls.com:

7z a secure.7z * -pSECRET 

Where:

7z        : name and path of 7-Zip executable a         : add to archive secure.7z : name of destination archive *         : add all files from current directory to destination archive -pSECRET  : specify the password "SECRET" 

To open :

7z x secure.7z 

Then provide the SECRET password

Note: If the password contains spaces or special characters, then enclose it with single quotes

7z a secure.7z * -p"pa$$word @|" 
like image 138
Gerard Rozsavolgyi Avatar answered Sep 20 '22 22:09

Gerard Rozsavolgyi


General Syntax:

7z a archive_name target parameters 

Check your 7-Zip dir. Depending on the release you have, 7z may be replaced with 7za in the syntax.

Parameters:

  • -p encrypt and prompt for PW.
  • -pPUT_PASSWORD_HERE (this replaces -p) if you want to preset the PW with no prompt.
  • -mhe=on to hide file structure, otherwise file structure and names will be visible by default.

Eg. This will prompt for a PW and hide file structures:

7z a archive_name target -p -mhe=on 

Eg. No prompt, visible file structure:

7z a archive_name target -pPUT_PASSWORD_HERE 

And so on. If you leave target blank, 7z will assume * in current directory and it will recurs directories by default.

like image 33
thebunnyrules Avatar answered Sep 19 '22 22:09

thebunnyrules