This question already has an answer here:
- Encrypt and Decrypt text with RSA in PHP 6 answers
I need to convert code from C# to PHP, with identical results. In C# I finished it pretty quickly, but now need to convert the following code to php:
public static string RsaDecrypt(string privateKey, string src)
{
CspParameters csp = new CspParameters();
csp.Flags = CspProviderFlags.UseMachineKeyStore;
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
rsa.FromXmlString(privateKey);
return RsaDecrypt(rsa, src);
}
public static string RsaDecrypt(RSACryptoServiceProvider rsa, string src)
{
byte[] srcData = Convert.FromBase64String(src);
byte[] destData = rsa.Decrypt(srcData, false);
return Encoding.UTF8.GetString(destData);
}
I'm trying to hours and I can not, I'm using the phpseclib0.2.1a file and the code:
The Problem in PHP is returning the following error:
Notice: Decryption error in E:\AppServWWW\Request\Flash\Crypt\RSA.php on line 1582
@EDIT: My $_GET["p"] is
cwQPQLSW%2FQ70AUmBzkZ9c7d9MrEAcPAAN1lRG937XZuibDOE304i8894uowlC1OANnWEim6suOxzhEHZl0BR1G1audk4CWG1TUSqAo4MO5FBfVbmcLVMx1KPV9%2FeMzil%2BHM1XwyX3Dm0h%2F0uAxORfpa3waq0iOemkUYBq2lXDEU%3D
</div>