破解 DES 的代码
我正在学习密码学,我需要开发 Java 或 C 代码来破解 DES(数据加密标准)。我知道 DES 中使用的算法,但我不知道应该如何用 Java 或 C 进行编码。我听说过 Java 加密体系结构,但我不确定如何使用它?有人可以为我提供一个简短的教程吗?
谢谢
I am studying Cryptography and I need to develop Java or C code to break DES(Data Encryption Standard). I am aware of the algorithm used in DES but I don't know how should I go about coding in Java or C. I have heard about the Java Cryptography Architecture but I am not sure how to use it ? Can someone provide me with a short tutorial for the same ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取决于您如何尝试“破坏”DES...我假设您正在尝试解密给定的密文(纯密文攻击)。
除了能够支持 DES 加密/解密的库之外,您可能还应该寻找一个支持密码分析的库,以了解如何实现这一点。暴力破解不需要这样的库,它就像迭代 56 位密钥的可能值并尝试解密密文一样简单。您几乎可以使用任何编程语言来实现此目的,只要它支持 DES。
如果您想要更复杂的东西,例如线性或差分密码分析,现代密码分析。该书中的代码示例使用 Python。您也可以考虑使用 Python 或 Ruby 等高级语言,因为与使用 C 语言实现相比,它可以加快您的开发过程,并且您不必处理由于内存管理、指针而导致的严重错误Python和Ruby都支持DES加密和解密。缺点是您的代码在较低级语言中可能会具有更高的性能(前提是您做得正确) - 因此,如果速度至关重要,则 C 与 OpenSSL(或任何其他支持 DES 支持的加密库)结合使用将是一个不错的选择。
密码分析库示例
Depends on how you attempt to "break" DES... I assume you are trying to decrypt a given ciphertext (ciphertext-only attack).
Apart from a library that is capable to support DES en-/decryption what you should probably additionally look for is a library that supports cryptanalysis to get a feel for how to implement this. Brute-forcing would require no such library, it's as simple as iterating over the possible values for a 56 bit key and trying to decrypt your ciphertext. You can take virtually any programming language for this, as long as it supports DES.
If you want something more sophisticated, e.g. linear or differential cryptanalysis, a good introduction is Modern Cryptanalysis. The code samples in that book use Python. You, too, could consider using a high-level language such as Python or Ruby because it speeds up your development process compared to implementing things in let's say C, and you won't have to deal with nasty errors due to memory management, pointers etc. Both Python and Ruby do support DES encryption and decryption. The downside is that your code will probably be more performant in a lower-level language (provided you're doing it right) - so if speed is of the essence, C in combination with OpenSSL (or any other crypto library with DES support) would be a good choice.
Examples for cryptanalysis libraries
有关 DES 攻击向量的参考,请参阅 DES Wiki 条目的安全部分1。
See the security section of the DES Wiki entry for references on DES attack vectors1.