Question

I'm using phpseclib for encrypting data, My MySQL database's encoding is utf8-general-ci. when I encrypt an string and save it to the table some of characters appears in '?' charachter. This make mistake when I want to decrypt it. What encoding should I use to have all of the characters? please help.

Was it helpful?

Solution

If you encrypt your data to a binary string, it can no longer be stored in an UTF8 encoded string, since some binary values/sequences are just not valid UTF8.

Just base64 encode your string (or change the column type to a binary type) before storing it and things should work better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top