如何让RSA加密相同的文本,密文每次不一样?

110来电 2012-06-15 10:51:18
rsa.FromXmlString(PRIVATE_KEY);
System.Security.Cryptography.RSAPKCS1SignatureFormatter f =
new System.Security.Cryptography.RSAPKCS1SignatureFormatter(rsa);
f.SetHashAlgorithm("SHA1");
Byte[] source = System.Text.ASCIIEncoding.ASCII.GetBytes(comboBox1.Text);
System.Security.Cryptography.SHA1Managed sha = new System.Security.Cryptography.SHA1Managed();
Byte[] result = sha.ComputeHash(source);
Byte[] regkey = f.CreateSignature(result);
richTextBox1.Text = Convert.ToBase64String(regkey);
...全文
568 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnfixit 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]
dsa.FromXmlString(PRIVATE_KEY);
System.Security.Cryptography.DSASignatureFormatter f = new System.Security.Cryptography.DSASignatureFormatter(dsa);
f.SetHashAlgorithm("SHA1");
Byte[] source =……
[/Quote]
这应该是加解密算法有关
cnfixit 2012-06-15
  • 打赏
  • 举报
回复
对rsa没有什么深入的了解,不过你的需求有点那什么了吧,就好比你要求你手里的钥匙不变,还可以打开不同的锁,万能钥匙?
110来电 2012-06-15
  • 打赏
  • 举报
回复
dsa.FromXmlString(PRIVATE_KEY);
System.Security.Cryptography.DSASignatureFormatter f = new System.Security.Cryptography.DSASignatureFormatter(dsa);
f.SetHashAlgorithm("SHA1");
Byte[] source = System.Text.ASCIIEncoding.ASCII.GetBytes(comboBox1.Text);
System.Security.Cryptography.SHA1Managed sha = new System.Security.Cryptography.SHA1Managed();
Byte[] result = sha.ComputeHash(source);
Byte[] regkey = f.CreateSignature(result);
richTextBox1.Text = Convert.ToBase64String(regkey);

DSA就可以
110来电 2012-06-15
  • 打赏
  • 举报
回复
不换私钥和公钥呢
cnfixit 2012-06-15
  • 打赏
  • 举报
回复
换了私钥,就不一样了
110来电 2012-06-15
  • 打赏
  • 举报
回复
目前得到的密文总是一样的

110,538

社区成员

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

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

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