How to create zip file with 256 bits encryption using php [duplicate]

有些话、适合烂在心里 提交于 2019-12-22 10:56:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!