PHP:使用自定义密码对 ZIP 存档进行编码时使用哪个 ZipArchive::EM_ 常量
PHP: Which ZipArchive::EM_ constant to use when encoding ZIP Archive with custom password
我对使用密码编码 zip 文件有疑问,可从 PHP v 7.2
获得
当我用方法编码ZIP时
ZipArchive::setEncryptionName
参数方法可以是:
- ZipArchive::EM_AES_128
- ZipArchive::EM_AES_192
- ZipArchive::EM_AES_256
有人可以告诉我/解释使用哪个以及为什么吗?
我现在正在使用 ZipArchive::EM_AES_256 因为我希望它是最安全的,但我的同事告诉我他无法打开它(他的zip 软件甚至不要求输入密码)。
那么有没有一种方法可以适用于所有情况?我们有在我国很多人使用的软件,很多老年人可能会得到这些 ZIP 文件,并且要求它们可以打开并且每个 zip 文件都有密码。
请考虑他们甚至可能使用 Windows XP 等
根据您的评论,Windows 无法在本地解密 AES 加密的存档,即使在 Windows 10 等最新版本中也无法解密(参见 why)。
PHP v8.0 添加了 "traditional pkware encryption" 这将允许 Windows 用户在没有第三方应用程序(7-Zip等)。
对于PHPv7.x,需要依赖shell commands or use a library that supports ZipCrypto encryption algorithm (sometimes called "pkware" - as per the company that created the zip format). Several out of the most popular zip libraries on packagist use ext-zip
, so they won't offer PKWARE encryption on PHP 7.x. However nelexa/zip doesn't and it supports pkware encryption.
我对使用密码编码 zip 文件有疑问,可从 PHP v 7.2
获得当我用方法编码ZIP时 ZipArchive::setEncryptionName
参数方法可以是:
- ZipArchive::EM_AES_128
- ZipArchive::EM_AES_192
- ZipArchive::EM_AES_256
有人可以告诉我/解释使用哪个以及为什么吗?
我现在正在使用 ZipArchive::EM_AES_256 因为我希望它是最安全的,但我的同事告诉我他无法打开它(他的zip 软件甚至不要求输入密码)。
那么有没有一种方法可以适用于所有情况?我们有在我国很多人使用的软件,很多老年人可能会得到这些 ZIP 文件,并且要求它们可以打开并且每个 zip 文件都有密码。
请考虑他们甚至可能使用 Windows XP 等
根据您的评论,Windows 无法在本地解密 AES 加密的存档,即使在 Windows 10 等最新版本中也无法解密(参见 why)。
PHP v8.0 添加了 "traditional pkware encryption" 这将允许 Windows 用户在没有第三方应用程序(7-Zip等)。
对于PHPv7.x,需要依赖shell commands or use a library that supports ZipCrypto encryption algorithm (sometimes called "pkware" - as per the company that created the zip format). Several out of the most popular zip libraries on packagist use ext-zip
, so they won't offer PKWARE encryption on PHP 7.x. However nelexa/zip doesn't and it supports pkware encryption.