请协助C#中的DES解密 [英] Please help with DES decryption in C#

查看:72
本文介绍了请协助C#中的DES解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在尝试使用DES
加密一个字符串在C#

Hi all,
I am attempting to
Encrypt a string use DES  in C#

  明文是     " NETB0000       0BD01,d9b9fccf552dc1de16fc31b62dfc82c5;"

 plaintext is     "NETB0000        0BD01,d9b9fccf552dc1de16fc31b62dfc82c5;"

 关键是" 48 42 4e 65 74 42 43 4e"

 the  key is  " 48 42 4e 65 74 42 43 4e "

正确的加密结果是

99,74,-26,4,-20,-13,42,-2,52,38,101,-103,-48,-28,11,-44,-42,-86,-108, 22,-109,-31,91,-100,98,90,-20,-18,9,-62,-57,20,-13,-27,88,-3,-47,-74, -63,-110,123,25,-72,-120,40,9,-63,-2,-111,-87,77,74,30,101,80,61,

99,74,-26,4,-20,-13,42,-2,52,38,101,-103,-48,-28,11,-44,-42,-86,-108,22,-109,-31,91,-100,98,90,-20,-18,9,-62,-57,20,-13,-27,88,-3,-47,-74,-63,-110,123,25,-72,-120,40,9,-63,-2,-111,-87,77,74,30,101,80,61,

但是 我使用 .net类" DESCryptoServiceProvider";加密结果不一样.

but  I use the .net class "DESCryptoServiceProvider" that Encrypt Result   is not the same.

请 救救我!

please  help me!

推荐答案

对于DES和所有其他对称加密算法,您需要两个必须相同的值才能进行加密和解密.这些是密​​钥和初始化向量(IV).

For DES and all other symmetric encryption algorithms you need two values that must be the same for encryption and decryption. These are the Key and Initialization Vector (IV). 

因此,您需要确保将用于解密的IV的值设置为与用于加密的IV相同的值.如果没有IV,则将无法解密消息.

So you need to make sure that you set the value for IV for decryption as the same of the IV used for encryption. If you don't have the IV you will not be able to decrypt the message.

IV很重要,因此重复使用相同的密钥将使攻击者无法猜测不同加密消息之间的关系.

The IV is important so that repeated use of the same key does not allow attackers to guess relations between different encrypted messages.


这篇关于请协助C#中的DES解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆