//有私钥strPrivateKey,有公钥strPublickKey,该私钥不包含该公钥;
//有密文strToDecrypt
RSACryptoServiceProvider cryptoServiceProvider = new RSACryptoServiceProvider();
cryptoServiceProvider.FromXmlString(strPrivateKey);
//记录下私钥对应的公钥
string strPublicKeyOfPrivateKey = cryptoServiceProvider.ToXmlString(false);
strDecrypted = cryptoServiceProvider.Decrypt(strToDecrypt, false);
//记录下密文对应的SHA1签名
strSignData = cryptoServiceProvider.Decrypt(strToDecrypt, SHA1);
//strDecrypted为能够正确解密的数据,接下来逆运算
RSACryptoServiceProvider cryptoServiceProvider2 = new RSACryptoServiceProvider();
cryptoServiceProvider2.FromXmlString(strPublicKeyOfPrivateKey);
strEncrypted = cryptoServiceProvider2.Encrypt(strDecrypted, false);
//按说strEncrypted应该就是strToDecrypt啊,但是就是不对,声明字符串转换肯定没问题。
//不过
RSACryptoServiceProvider cryptoServiceProvider3 = new RSACryptoServiceProvider();
cryptoServiceProvider3.FromXmlString(strPublickKey);//此处为公钥
bool bOK = cryptoServiceProvider3.VerifyData(strToDecrypt,SHA1,strSignData);
//bOK为true验证通过。
//问题:
//根据这些条件,怎么样才能够正确的加密,确保strEncrypted==strToDecrypt?