$key = openssl_get_publickey('provided_public_key'));
openssl_public_decrypt(base64_decode($_GET['signature']), $hashExpected, $key);
以上代码 在c#中如何实现 ?
openssl_get_publickey openssl_public_decrypt c# 中如何实现
------解决思路----------------------
建议用BouncyCastle(nuget链接),如果你的public key是个pem格式的文件,signature是一个base64的字符串,那么代码如下:
RsaKeyParameters pubkey;
using (var sr = new StreamReader("e:\\pubkey.pem"))
{
var pemReader = new Org.BouncyCastle.OpenSsl.PemReader(sr);
pubkey = (RsaKeyParameters)pemReader.ReadObject();
}
var cipher = CipherUtilities.GetCipher("RSA/NONE/PKCS1PADDING");
cipher.Init(false, pubkey);
var data = Convert.FromBase64String(signature);
var hashExpected = cipher.DoFinal(data);
hashExpected就是解密后的字节数组
------解决思路----------------------
RSA算法和语言无关