7-Zip 命令在 Windows 上创建和解压缩受密码保护的 ZIP 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28160254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
7-Zip command to create and extract a password-protected ZIP file on Windows?
提问by user3254893
On Mac/Linux to zip/unzip password protected zip files, I use: Zip:
在 Mac/Linux 上压缩/解压缩受密码保护的 zip 文件,我使用: 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)?
Windows 上命令行的等效命令是什么(假设已经安装了 7zip)?
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
我一直在做研究,发现无法使用 Java zip4j 库进行密码加密。Windows 也没有像 Mac/Linux 这样的 zip 命令提示符
回答by Gerard Rozsavolgyi
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
然后提供SECRET密码
Note:If the password contains spaces or special characters, then enclose it with single quotes
注意:如果密码包含空格或特殊字符,则用单引号括起来
7z a secure.7z * -p'pa$$word @|'
回答by thebunnyrules
General Syntax:
一般语法:
7z a archive_name target parameters
Check your 7-Zip dir. Depending on the release you have, 7zmay be replaced with 7zain the syntax.
检查您的 7-Zip 目录。根据您拥有的版本,7z可能会在语法中替换为7za。
Parameters:
参数:
- -pencrypt and prompt for PW.
- -pPUT_PASSWORD_HERE(this replaces -p) if you want to preset the PW with no prompt.
- -mhe=onto hide file structure, otherwise file structure and names will be visible by default.
- -p加密并提示输入密码。
- -pPUT_PASSWORD_HERE(替换-p)如果您想在没有提示的情况下预设密码。
- -mhe=on隐藏文件结构,否则默认情况下文件结构和名称将可见。
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 targetblank, 7z will assume * in current directory and it will recurs directories by default.
等等。如果您将目标留空,7z 将假定 * 在当前目录中,并且默认情况下它将递归目录。
回答by FearlessCoward
To fully script-automate:
完全脚本自动化:
Create:
创建:
7z -mhc=on -mhe=on -pPasswordHere a %ZipDest% %WhatYouWantToZip%
Unzip:
解压:
7z x %ZipFile% -pPasswordHere
(Depending, you might need to: Set Path=C:\Program Files\7-Zip;%Path% )
(视情况而定,您可能需要: Set Path=C:\Program Files\7-Zip;%Path% )
回答by JustCoding
I'm maybe a little bit late but I'm currently trying to develop a program which can brute force a password protected zip archive. First I tried all commands I found in the internet to extract it through cmd... But it never worked....Every time I tried it, the cmd output said, that the key was wrong but it was right. I think they just disenabled this function in a current version.
我可能有点晚了,但我目前正在尝试开发一个程序,该程序可以暴力破解受密码保护的 zip 存档。首先我尝试了我在互联网上找到的所有命令,通过cmd提取它......但它从来没有工作......每次我尝试它时,cmd输出都说,密钥错误但它是正确的。我认为他们只是在当前版本中禁用了此功能。
What I've done to Solve the problem was to download an older 7zip version(4.?) and to use this for extracting through cmd.
我为解决问题所做的工作是下载旧的 7zip 版本(4.?)并使用它通过 cmd 进行提取。
This is the command: "C:/Program Files (86)/old7-zip/7z.exe" x -pKey "C:/YOURE_ZIP_PATH"
这是命令:"C:/Program Files (86)/old7-zip/7z.exe" x -pKey "C:/YOURE_ZIP_PATH"
The first value("C:/Program Files (86)/old7-zip/7z.exe") has to be the path where you have installed the old 7zip to. The x is for extract and the -p For you're password. Make sure you put your password without any spaces behind the -p! The last value is your zip archive to extract. The destination where the zip is extracted to will be the current path of cmd. You can change it with: cd YOURE_PATH
第一个值("C:/Program Files (86)/old7-zip/7z.exe") 必须是您安装旧 7zip 的路径。x 用于提取,-p 用于您的密码。确保您将密码放在 -p 后面没有任何空格!最后一个值是您要提取的 zip 存档。zip 解压缩到的目的地将是 cmd 的当前路径。您可以使用以下命令更改它: cd YOURE_PATH
Now I let execute this command through java with my password trys. Then I check the error output stream of cmd and if it is null-> then the password is right!
现在我让我用我的密码尝试通过 java 执行这个命令。然后我检查cmd的错误输出流,如果它是空的->那么密码是对的!