I have written a piece of code which, for testing purposes, only encrypts and then decrypts some text.
I used phpseclib
and it works well. When I store encrypted text in a mysql database, and then retrieve it from there and try to decrypt it, I get a decryption error. In order to store encrypted text in the database I have to use addslashes()
php function, and then stripslashes()
later before decrypting. When I compare the string I stored in the database, it's exactly the same after stripping slashes, but somehow decryption doesn't work.
Is this a common problem? Is there a special way to create a database that will hold all the characters that RSA produces?