有人可以解释一下openssl cli和c ++ DES输出的差异吗?



使用openSSL,我的一个程序正在产生与openSSL的命令行实用程序不同的加密输出。 使用"aaaa"作为纯文本,"A"作为键,我一直在运行

openssl enc -des -e -nosalt -in test1.txt -out test1out.txt

获取示例加密,但我的示例程序 (http://pastebin.com/e4P0DGYR) 永远不会产生相同的哈希。

要运行示例程序,请输入

./a.out 40 42 $(hexdump -ve '1/1 "%.2x"' test1.txt) $(hexdump -ve '1/1 "%.2x"' test1out.txt)

我用这个(http://www.codealias.info/technotes/des_encryption_using_openssl_a_simple_example)作为例子。

正如您在openssl用户邮件列表中发布此内容时有人回答的那样,CLI 使用 ECB 模式,程序使用 CFB 模式。DES-ECB与DEC-CFB(或任何其他模式)不同。

最新更新