Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

storing encrypted data

Status
Not open for further replies.

skiflyer

Programmer
Joined
Sep 24, 2002
Messages
2,213
Location
US
Does anyone have experience storing encrypted data in MySQL with PHP?

I'm having some difficulties... here's my routine.
Code:
  $store_data = @mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB);
  $store_data = addslashes($store_data);
  //Insert into database
  //Retrieve from database
  $store_data = stripslashes($store_data);
  $stored_data= mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $store_data, MCRYPT_MODE_ECB);

And I get back data which I can't decrypt... if I strip out the insert/retrieve to database portion it runs just fine. And I'm storing this as a blob... I'm guessing this is a problem with character encodings?

Not certain, would love any suggestions, or ear flicks if I've just made a silly mistake.

-Rob
 
I'm going to hang my head in shame now.

I had of course functionalized the saveData, loadData portions of my code. And I was passing saveData an empty string for the data because of a mis-spelling... hence, all my returns were blank.

ugh.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top