[英]PHP8 ZipArchive EM constant TRAD_PKWARE not working
i used ZipArchive::EM_TRAD_PKWARE, with password, but zip file is not encrypted.我使用了带有密码的 ZipArchive::EM_TRAD_PKWARE,但 zip 文件未加密。 I think that pkware not working.
我认为 pkware 不工作。 Have solutions?
有解决方案吗?
Thx谢谢
$zip->setEncryptionName('test.txt', ZipArchive::EM_TRAD_PKWARE, 'PASSWORD');
I got it working by the following example and rules:我通过以下示例和规则使其工作:
I got inconsistent results when not following these 2 rules:不遵循这两条规则时,我得到了不一致的结果:
addFile
is called before setEncryptionName
setEncryptionName
之前调用addFile
Create the following test.txt file with the following content:使用以下内容创建以下 test.txt 文件:
test
Add the following PHP code to test.php:添加以下 PHP 代码进行测试。php:
$zip = new ZipArchive();
$zip->open("test.zip", ZipArchive::CREATE);
$zip->addFile("test.txt");
$zip->setEncryptionName('test.txt', ZipArchive::EM_TRAD_PKWARE, 'PASSWORD');
$zip->close();
php test.php
A zip file is now created which prompts for a password on unzip.现在创建了一个 zip 文件,它会在解压缩时提示输入密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.