How to use Asymmetric Encryption for Storing Data in MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RudyG
Forum Newbie
Posts: 2
Joined: Mon Apr 02, 2007 2:33 pm

How to use Asymmetric Encryption for Storing Data in MySQL

Post by RudyG »

I've been searching for days and I'm unable to get a good handle on this problem. I've found a treasure trove of "theoretical" articles on the subject - its seems possble - but almost no implementation examples. Any advise and practical examples would be much appreciated.

Here's what I'm trying to do... I'm collecting data from users and want to store it encrypted within MySQL. I want to use Asymmetric Encryption so that script uses a public key to encrypt, and a "secret" private key is used to decrypt. Obviously, the private key is NEVER stored on the server in any way. The decrypt script/function would only be accessible to the admin, and the private key must be entered manually by the admin via a SSL connection whenever they want to view any data in the database.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

seems to me that once the data is encrypted you can put it wherever you want. What does encryption have to do with storage?

If you only want encryption at the storage layer you could implement a translator in the form of a data object. Read: viewtopic.php?t=48499 and imagine an "encrypt" and "decrypt" function in the getValue() and setValue() methods.

btw - awesome article Mauggs!
RudyG
Forum Newbie
Posts: 2
Joined: Mon Apr 02, 2007 2:33 pm

Post by RudyG »

Kieran Huggins wrote:seems to me that once the data is encrypted you can put it wherever you want. What does encryption have to do with storage?
Very astute - encryption has nothing to do with storage... But since I began researching this project, I've seen NO examples of using Asymmetric Encryption within php code. Therefore, my question includes it's use in context.

I'm looking for info and help regarding the use of Asymmetric Encryption within php - not a DB wrapper... Thanks anyway...
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

RudyG,

check openssl functions http://www.php.net/manual/en/ref.openssl.php

Take into account that asymmetric keys are usually pretty long, so you have to consider other methods than entering a key in a web form.
Post Reply