问题
Possible Duplicate:
Create an encrypted zip archive with PHP
How to create zipped file with 256 bits encryption using PHP
If there is any example it'll be great
回答1:
On Linux you can use 7zip to create AES encrypted zip files:
exec("7z a -p$PASSWORD -mem=AES256 -tzip $ZIP $SOURCE");
Courtesy of Nfabio from http://ubuntuforums.org/archive/index.php/t-1694923.html
Be sure to apply escapeshellarg().
Note: While this approach will work, but it is better not to call out to the shell with an embedded password. As of php 7.2, this will no longer be necessary because php now natively supports AES zip encryption.
回答2:
As I remember, PHP zip classes(I saw)/extension don't support encryption, so for a portable solution I suggest you to:
- Compress your file then encrypt it.
- Use the WinZip compatible version to encrypt your file.
来源:https://stackoverflow.com/questions/13483614/how-to-create-zip-file-with-256-bits-encryption-using-php