How to password protect zip in php?

I can create a zip file using ziparchive lib in php. Is there a way to specify a password for the zip files that I create? Is there another user library that can do the same?

My php works in safe mode and my hosting provider does not allow me to change it. Therefore, I cannot execute the shell_exec () function. Is there any other way to use it with any other library? I checked the DotNetZip library, but it says that it only supports .net languages ​​and in windows, nothing is related to php. I also use a Linux server.

The application is that I have several xml files that are dynamically generated and need to be fixed, and my clients will download them. But I need to enter a password so that even if someone intercepted it, they could not open it.

Or is there an alternative way?

+4
source share
2 answers
shell_exec('zip -qjP <password> <archive> <file1> <file2> ... <file_n>'); 
+3
source

use this:

 system('zip -P password zipfile.zip file.extension'); 

pass is the password, and the .extension file will be archived in zipfile.zip.

works on windows and linux

0
source

Source: https://habr.com/ru/post/1399663/


All Articles