Ne-Lexa / php-zip

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

setReadPassword version php5.6 #65

Closed 529834149 closed 4 years ago

529834149 commented 4 years ago

Description

Example

When I generated the compressed package, the password of the compressed package did not take effect, `//本次的最新数据全部写完到bcp文件 关闭文件
isset($open)?@fclose($fopen):$open=null;

            //压缩文件名称 不区分公安还是网信办 time为文件压缩打包的时间戳
            $zipname = "data_".time().".zip"; 

            //压缩文件夹   
            $this->zipfile->addDirRecursive($beforepath); // save the archive to a file 
            // $this->zipfile->setReadPassword('run1234!@#');
            // $encryptionMethod = \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256;

            // $this->zipfile->setPassword('run1234', $encryptionMethod);  
            $this->zipfile->setReadPassword('run1234');
            $this->zipfile->saveAsFile($zippath.'/'.$zipname);
            $this->zipfile->close(); `
Ne-Lexa commented 4 years ago

Use ZipFile::setPassword()

529834149 commented 4 years ago

header big

`//本次的最新数据全部写完到bcp文件 关闭文件
isset($open)?@fclose($fopen):$open=null;

            //压缩文件名称
            $zipname = "data_".time().".zip"; 

            //压缩文件夹   $zipFile = new \PhpZip\ZipFile();
            $this->zipfile->addDirRecursive($beforepath); // save the archive to a file 
        $this->zipfile->setPassword('run1234!@#');
        $this->zipfile->saveAsFile($zippath.'/'.$zipname);
        $this->zipfile->close();  `

Fatal error: Call to undefined function PhpZip\IO\Filter\Cipher\WinZipAes\random_bytes() in F:\xampp\htdocs\bokee_upload_data\vendor\nelexa\zip\src\IO\Filter\Cipher\WinZipAes\WinZipAesEncryptionStreamFilter.php on line 104

Ne-Lexa commented 4 years ago

You haven't installed the random_compat dependency, which is required for PHP < 7.

Execute:

composer require paragonie/random_compat
529834149 commented 4 years ago

Thank you. I think it's faster than before. The version of 3.0.2 used before is now upgraded to 3.3. The speed is faster and the compression and decompression are normal. Thank you very much