NYCPHP Meetup

NYPHP.org

[nycphp-talk] Secure Data

Hans Zaunere hans at nyphp.org
Thu Jul 17 21:36:18 EDT 2003



Rudy Gamberini wrote:

> I need to collect sensitive information on one of my web pages.  I have 
> established a secure session https:// utilizing my hosting service's 
> certificate.  Now that the session is secure I need to be sure the 
> collected data is secure.  While I could encrypt the data before storing 
> it in the MySQL database, I need to be able to decrypt it eventually to 
> process the orders.  I've used MD5 hash function to encrypt passwords I 
> store in cookies but that approach would not work here.

Technically, MD5 isn't encryption - it's a one way digest, ie, you can't determine the original data from the digest.  And as Dan pointed out, easily hijacked (but you're using SSL, so it's much better, but still suseptible to cookie browsing if someone has local machine access).

> I need to hold 
> the key locally, meaning on a machine outside the web-server that will 
> be able to decrypt the information after retrieving it.
>  
> I like the idea that the database only stores encrypted data that way 
> should the database be compromised the information stored there will be 
> of little value. 

MySQL 4.x series supports some things that may help:

http://www.mysql.com/doc/en/Miscellaneous_functions.html  (search for variations of 'encrypt')
http://www.mysql.com/doc/en/Secure_connections.html


But keep in mind; if the server on which the key resides is compromised, the game's over.  Encryption like this is a vicious circle; just be sure your server isn't cracked :)

H





More information about the talk mailing list