1

I am having a little issue with storing mcrypt_module_open('rijndael-256','','ofb',''); in a MySQL db.

When it inserts the encrypted data into the MySQL db it looks like this ˜9ÏÏd‰.

It should look like this

÷`¥¶Œ"¼¦q…ËoÇ

I am wondering if I have to do something to get it to work?

Jason
  • 15,017
  • 23
  • 85
  • 116
RussellHarrower
  • 6,470
  • 21
  • 102
  • 204

3 Answers3

3
  • Use a blob field type for storing binary data (BLOB, VARBINARY, BINARY)
  • If you're not doing this already: escape your values with the proper methods if you're using them directly in a SQL-statement. Or even better: use query parameters/prepared statements.
  • As a last resort you could just encode your data with either base64_encode or bin2hex.
  • If you want to display binary data on the console or in the browser (even for debugging purpose) use one of those encodings too. Otherwise you might not see the actual data because the browser might not display your binary correctly.
vstm
  • 12,407
  • 1
  • 51
  • 47
1

In general, it might be a good idea to base64 encode and decode binary data like this. See Best way to use PHP to encrypt and decrypt passwords? .

Community
  • 1
  • 1
fratrik
  • 1,700
  • 2
  • 15
  • 17
0

Have you tried to Collation of your table that your character supports.

The characters '÷`¥¶Œ"¼¦q…ËoÇ' looks like UTF-8 or someother charset, find charset of your characters and update table Collation based your charset

Robin Michael Poothurai
  • 5,444
  • 7
  • 23
  • 36