Home > Software design >  Cant store encrypted Integer in Database
Cant store encrypted Integer in Database

Time:02-25

I am Developing a website using Laravel that accept Online payment with Credit card and this must be encrypted before storing into the database I am Using RC4 Encryption to encrypt an integer then store it in my database it throwing an error cause after encryption it looks like that r ���`�q� so weird symbols and logos it cannot be stored as my database collation is utf16 general_ci I used something else but it didn't work [This Error1

CodePudding user response:

Encrypted data is generally binary data, and the characters you show in your question suggest that's the case in your application.

A good solution to your problem is to use base64_encode() to convert your encrypted binary data to text before putting it into MySQL, and base64_decode() to get back the binary data after you read it from MySQL.

Warning: RC4 encryption is not secure. It's been cracked for almost a decade. If you use it to store sensitive credit card data, it is very likely that cybercriminals will steal that data. Your customers won't like that.

If you want to handle credit card data, your best bet is to use a payment service provider like stripe.com, paypal, or one of many others. You don't want credit card numbers, even encrypted ones, stored in your database.

  • Related