Page 1 of 1
Zip 2.0 Encryption
Posted: Wed Dec 06, 2006 6:22 am
by mikesmith76
Hi all,
I need to send a file in "standard 2.0 encryption" (not my words). I have no control over this format as it is going to an external company, and this is the format the file must be sent in. Inside the encrypted zip file will be a csv file, possibly growing to several thousand lines a time. I have seen the excellent zip file classes around the forum (and on other places) but none that I have seen support zip encryption. To tell you the truth I'm not even sure what they been by "standard 2.0 encryption".
Has anybody else faced a similar need to send encrypted zip files, and found a suitable solution.
Thanks for all your help
Posted: Wed Dec 06, 2006 6:36 am
by CoderGoblin
You don't mention which system you are working on (Linux/Windows).
I would use
exec a system command to zip the file before sending. Just google for "zip standard 2.0 encryption" for applications handling it on your platform. Doing this means if you ever need zip standard 3.0 encryption (doesn't exist yet as far as I know), your system just needs to be updated with the relevant application. If both you and your client use the same application you can guarantee you both can unzip each others zip files.
The alternative is to use the
PECL Zip utility but I am not sure which encrytion it uses. I would imagine it would be correct but you may want to send a test file first.
Posted: Wed Dec 06, 2006 6:39 am
by mikesmith76
Sorry the app is hosted on a dedicated linux server that I have command line access to. Just searching now on what command line tools are available for use. From what i've read on the security aspect of the format it's not much better than having no password set, but we do what were told...
Posted: Wed Dec 06, 2006 9:55 am
by mikesmith76
Sorry to be a moron but i have a problem with the Linux "zip" command
If i run the following command (both on the command line and in php) all is well
zip /test/test.zip /test/test.csv
However to encrypt the contents i need to use the -e flag as in
zip -e /test/test.zip /test/test.csv
Doing this on the command line results in a prompt for a password. I have tried to replicate this functionality in using both proc_open and popen, no luck with either. With proc_open all i get returned is "Command Returned 16". popen is one way to no feedback there, and no zip file either. The code I used for both of the above commands was taken from the php manual examples (as i have never used either of these commands before).
This is to be hosted on a Linux server, running php 4.2 I think. I don't want to upgrade the version of php as a number of other apps are running on this server, and i don't want to check each and every one for bugs after the upgrade.
I'm probably doing something really stupid, if anyone want's to point me in the right direction I would appreciate it
Posted: Wed Dec 06, 2006 12:32 pm
by feyd
There's a zip class in Code Snippets too.

Posted: Thu Dec 07, 2006 6:46 am
by mikesmith76
If I was just trying to zip up the file that would be great. Reading through the class you mentionned it doesn't appear to support password protection of any kind, and I'm a bit reluctant to resurrect a 6 month old thread to speak to the class author.
After spending the afternoon playing with popen / proc_open i'm not sure I can do what I want with my current php version. Need more digging I suppose...
Posted: Thu Dec 07, 2006 6:59 am
by onion2k
Write a Bash (or whatever shell is on the server) script that acts as a wrapper. You're really going to need command line access to get it working though, or the help of someone who has access.
Posted: Thu Dec 07, 2006 7:04 am
by mikesmith76
In the process of drawing up a quick bash script that will take the required password as a parameter. It's to be hosted on a dedicated server so I haev complete command line access. Think this problem could be a great learning experience!!