Well, as a newcomer to encryption, I have finally got a great system worked out. The problem is, i'm pretty sure it's breaking my SQL queries. If any of you could help me out, I'm sure it's something I have easily overlooked. This is the code I used to generate the keys:
include('Crypt/RSA.php');
$rsa = new Crypt_RSA();
extract($rsa->createKey());
And this is the code for encryption:
openssl_public_encrypt($data, $encrypted, $publickey);
return $encrypted;
All of this above works fine, and I have it called via a function. All the encryption itself works. The problem is that when I attempt to store the values in the MySQL database, my query randomly fails.
When I print the query to debug, I see the encrypted string
'��y�6u�������2�N����:������7�����Bï¿ ½ï¿½ï¿½ï¿½<�������7�;[�N\�����y/�X��ßÖŸ*���
=�-�����Z�EI)�'�cy/� I��#?��1Gh��$�d�
which will sometimes end the query string prematurely. I am wondering if there is a specific charset I should specify or if I need to change the MySQL datatype (it was set to LONGTEXT then LONGBLOB).
Thanks again in advance!