Re: Protected ZIP file with password

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Petrus Bastos wrote:
> Hey folks,
>
>     Do you know how can I create a protected zip file with password? Is
> there anyway? I've search on the internet, but without success.
>
> Thank's in advance,
> Petrus Bastos.
>
>   
The easiest way to accomplish this would be to write a wrapper function
using the zip tool provided by (almost every) Linux distribution.

<?php

function zip($directory, $password, $saveAs) {
        return exec("zip -r $saveAs -P $password $directory";
}

print zip("/home/nick", "mypass", "/tmp/homebackup.zip");

?>

Please note: the -P flag can be monitored on the local system so it is
considered insecure.
If you're going to be accepting input, you should also wrap your
variables in escapeshellarg()

http://us3.php.net/zip
http://us.php.net/manual/en/function.exec.php

from the zip manual entry

THIS IS INSECURE!  Many multi-user operating  sys-tems
provide ways for any user to see the current command line of any other
user; even on stand-alone
systems there is always the threat of over-the-shoulder peeking. 
Storing the plaintext  password  as
part of a command line in an automated script is even worse.  Whenever
possible, use the non-echoing,
interactive prompt to enter passwords.  (And where security is truly
important, use strong encryption
such  as  Pretty  Good Privacy instead of the relatively weak encryption
provided by standard zipfile
utilities.)

==================
Nick Stinemates (nick@xxxxxxxxxxxxxx)
http://nick.stinemates.org

AIM: Nick Stinemates
MSN: nickstinemates@xxxxxxxxxxx
Yahoo: nickstinemates@xxxxxxxxx
==================

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux