Ne-Lexa / php-zip

PhpZip is a php-library for extended work with ZIP-archives.
MIT License
491 stars 60 forks source link

Can't setPassword on PHP 5.6 #56

Closed byungjikroh closed 4 years ago

byungjikroh commented 4 years ago
Q A
Library version(s) affected: 3.3.0
PHP version(s): 5.6.40
OS (with bit depth): macOS Catalina 10.15.4

Description

There is an error to set password under PHP 7 because it uses 'random_bytes' which is add in PHP 7

How to reproduce

$zipFile->setPassword('password')

Possible Solution

Use the depreciated 'randomBytes' function in src/Util/CryptoUtil.php for under PHP 7

Additional context

Fatal error: Call to undefined function PhpZip\IO\Filter\Cipher\WinZipAes\random_bytes() in /Applications/XAMPP/xamppfiles/htdocs/thecallcokr/vendor/nelexa/zip/src/IO/Filter/Cipher/WinZipAes/WinZipAesEncryptionStreamFilter.php on line 104

Ne-Lexa commented 4 years ago

Hello. The library uses the polyfill package "paragonie/random_compat". Check your composer.json file and the "replace" section for possible removal of the "paragonie/ andom_compat" library from the dependencies.

byungjikroh commented 4 years ago

Thanks.

There was no "replace" section on composer.json. But I added "paragonie/ andom_compat" manullay with 'composer require paragonie/random_compat:\<9.99' and it is resolved.