Reputation: 550
I am able to create zip file using ziparchive lib in php. Is there any way I can specify a password for the zip files that I create? Is there any other custom library that can do the same?
My php is running in safe mode and my hosting provider does not allow me to change it. So I'm not able to do shell_exec() function. Is there any other way around it by using any other library? I checked the DotNetZip Library, but it says it supports only .net based languages and in windows, nothing related with php is mentioned. Also I'm using a linux server.
The application is that I have a few xml files that are dynamically generated and need to be zipped and my clients will download it. But I need to put a password so that even though anyone intercepts it, they won't be able to open it.
Or is there any alternative way?
Upvotes: 4
Views: 6021
Reputation: 4607
use this:
system('zip -P password zipfile.zip file.extension');
pass is the password, and file.extension will be zipped into zipfile.zip.
works on Windows and Linux
Upvotes: 0
Reputation: 2993
shell_exec('zip -qjP <password> <archive> <file1> <file2> ... <file_n>');
Upvotes: 4