views:

200

answers:

2

I'm g-zipping and backing-up my database dump (using mysqldump ) to amazon S3 . all works fine, but i also need to encrypt this big-compressed file for securing the very- sensitive data within the database.

please help, i'm really lost here .

Thanks in advance :)

+1  A: 

First, have a look at Pro PHP Security by Chris Snyder and Michael Southwell from Apress. It will tell you all you need about encryption. There's a lot there.

From there you can download the source code for the book and look for a file called mcrypt.php in Chapter 6. It also comes with a sample implementation.

Good luck! And if it's useful to you, buy the ebook or dead tree version of the text. It's very informative and will teach you a lot! I'm not affiliated with Apress or the authors in any way, I'm just someone that found the book extremely useful.

Mark Moline
Thanks Mark. i took a glance on the mcript library, but it does not seems to provide methods to work directly with large files, without opening them with php ( getcontents or so.. ). the database dump can be REALLY BIG.. and i need lightweight and fast way to encrypt it.
For those really big files you're probably better off doing the dump, compression, and encryption from a cron shell script. Then use your PHP job to upload the finished files to s3. You should also consider bzip2 instead of gzip. It's slower, but the finished files are much smaller than gzip.
Mark Moline
i still cant find solution for the main prob -how to encrypt a file without physically load it to php .
Try "gpg" from the command line. Put it in the shell script that does the mysqldump and bzip2 compression.
Mark Moline
A: 

Thank Mark. After a short goggling about the "gpg" you mentioned, i found good article explaining exactly how to solve the problem: http://devzone.zend.com/article/1265