AES_ENCRYPT / DECRYPT HELP
Posted: Mon Mar 09, 2009 3:39 pm
Here is my issue -
I have a database with maybe 60 fields in it. Only 3 of the fields need to be encypted in my database (MySQL), one of which is the users Social Security Number.
I have read that if you want to use AES_ENCRYPT, then the field must be binary. I have done this, and the insert statement reads as follows:
That seems to work fine - I don't get any errors and there is something written to the database. The problem occurs when I try to use AES_DECRYPT. Because it's not a PHP function, I guess you have to use it in the SELECT statement. But I am unsure how to do that - I have seen it done as follows:
But how do I incorporate the above into my overall select statement, which right now is a simple
Like I said, I don't need all 60 fields decrypted, only a few.
Thanks
I have a database with maybe 60 fields in it. Only 3 of the fields need to be encypted in my database (MySQL), one of which is the users Social Security Number.
I have read that if you want to use AES_ENCRYPT, then the field must be binary. I have done this, and the insert statement reads as follows:
Code: Select all
INSERT INTO $usertable values( //...about 25 fields here, AES_ENCRYPT('$SSN', 'text_key'), //... about 30 fields here);Code: Select all
SELECT AES_DECRYPT( SSNbr, 'text_key' ) AS decrypted FROM $usertable.Code: Select all
"SELECT * FROM $table";Thanks