加密代码:
public static string RSADecrypt( byte[] DecryptString , string xmlPrivateKey)
{
byte[] DypherTextBArray;
string Result;
System.Security.Cryptography.RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlPrivateKey);
DypherTextBArray = rsa.Decrypt(DecryptString, false);
Result = (new UnicodeEncoding()).GetString(DypherTextBArray);
return Result;
}
解密代码:
public static string RSAEncrypt( byte[] EncryptString, string xmlPublicKey)
{
byte[] CypherTextBArray;
string Result;
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlPublicKey);
CypherTextBArray = rsa.Encrypt(EncryptString, false);
Result = Convert.ToBase64String(CypherTextBArray);
return Result;
}
结果:
jtjNm+SIYWobH79+RbRJL61yvWNj+fCP3c4tu12PD6VlpF24302gVqcPNrz31VE77wkFHWfNH6YPW/ShQsQwq1OfJBMuJjwaKMl8J1QtIUJjgjtOtxk2Y/6YAfco7FEtnzIGXRaQBruH7GIe+cun1jg7zM8aoZRqVidgBwFwGIo=
xb:49a10b35f7c398157fb70440f38621a5
zxx:709328a17a5a4a59bffebb37411f8a25
hdd:8d7025c63387cff68cd0083da2c53814
xb:63612c9d936c317a998422c353810cf4
yxj:f209dd3c6bf6960266429562a5c1d526
dzf:a6a9968b70df449b8cc00ffdc1b35ecc