【发布时间】:2014-04-22 09:53:56
【问题描述】:
我尝试使用 pyDes 和 Crypto.Cipher.DES 模块来实现 DES 算法。我发现一个问题,当我用82514145 密钥加密然后用93505044 解密密码时,我可以检索解密的文本。我发现 256 个键的行为是这样的。这是违反密码学的。我的代码如下:
from Crypto.Cipher import DES
plain_text = 'asdfghij'
print 'plain Text: ', plain_text
des = DES.new('82514145', DES.MODE_ECB)
cipher_text = des.encrypt(plain_text)
print 'the cipher text is ', cipher_text
des = DES.new('93505044', DES.MODE_ECB)
print 'the decrypted text is: ', des.decrypt(cipher_text)
输出是:
plain Text: asdfghij
the cipher text is @�Z����
the decrypted text is: asdfghij
我的工作有什么错误吗?我也用 pyDes 得到了同样的结果。
【问题讨论】:
-
在DES的不同分组密码模式中观察到相同的情况
标签: python cryptography des encryption-symmetric pycrypto