php-zip
php-zip copied to clipboard
Password madness
| Q | A |
|---|---|
| Library version(s) affected: | 3.1.9 |
| PHP version(s): | 7.2 |
| OS (with bit depth): | Win 10 x64 (A) + debian stretch x64 (b) |
Description
for sys A no traditional encrypted password is working at all when creating a new archive. it sets a password, and when then trying to extract the archive (with any tool like winrar, winzip, windows explorer ) the given password does not work.
for sys B the behaviour is quite similar, but here passwords without special hcars do work and passwords with special chars do not work when trying to extract the created archive.
How to reproduce
$password = 'whatever';
(new ZipFile) ->addFromString($path, $xml) ->setPassword($password, ZipFileInterface::ENCRYPTION_METHOD_TRADITIONAL) ->saveAsFile($zipPath) ->close();
Windows supports only PKWARE and ZipCrypto password encrypted ZIP files.
Try this:
use PhpZip\Constants\ZipEncryptionMethod;
// ...
$zipFile->setPassword('password', ZipEncryptionMethod::PKWARE);