I'm trying to encrypt a string in Unity3D and then decrypt it in PHP with phpseclib.
Unity C# code:
/* this is done further up
CspParameters csp = new CspParameters();
csp.KeyContainerName = publicKey;
rsa = new RSACryptoServiceProvider(csp)*/
private string rsaEncrypt(string s)
{
byte[] b = rsa.Encrypt(System.Text.Encoding.UTF8.GetBytes(s), true);
return Convert.ToBase64String(b);
}
PHP code:
$encrypted = $_GET["enc"];
$rsa = new Crypt_RSA();
$rsa->loadKey($rsaPrivateKey);
$decrypted = $rsa->decrypt(base64_decode($encrypted)) or die();
echo base64_encode($decrypted);
The problem i get is on the php part where i get this message:
Notice: Decryption error in RSA.php on line 2625
I believe that the problem is the format of $encrypted but i can't seem to figure out how to solve it, any help is much appreciated.