看一下这段代码问题在哪!!!

炫舞十风 2012-04-23 02:21:33
关于RSA加密算法 里面有三个参数n e d ,(n,e)-公钥 (n,d)-私钥 现在私钥加密,公钥解密
现在已经得到n,e,d 代码如下:
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSAParameters RSAInfo = RSA.ExportParameters(true);
string strN = BitConverter.ToString(RSAInfo.Modulus).Replace("-", "");
string strD = BitConverter.ToString(RSAInfo.D).Replace("-", "");
string strE = BitConverter.ToString(RSAInfo.Exponent).Replace("-", "");这些都是十六进制字符串形式

BigInteger biN = BigInteger.Parse("0" + strN, System.Globalization.NumberStyles.HexNumber);
BigInteger biD = BigInteger.Parse("0" + strN, System.Globalization.NumberStyles.HexNumber);
BigInteger biE = BigInteger.Parse("0" + strN, System.Globalization.NumberStyles.HexNumber);将字符串形式转换成大数

strA="22AA758271D153577E65487BD3AE554AA1D72377"; 明文strA
BigInteger biA = BigInteger.Parse("0" + strA, System.Globalization.NumberStyles.HexNumber);将十六进制明文转化成大数

BigInteger biEncry=BigInteger.ModPow(biA,biD,biN); //biEncry(密文)=biA(明文)^biD mod biN RSA加密算法

BigInteger biDncry=BigInteger.ModPow(biEncry,biE,biN);//解密文 biEncry(密文)^biE mod biN

为什么解密得到的biDncry与原明文biA不相同
...全文
42 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧