我正在编写一个程序来与另一个用python编写的程序进行交互。我发现加密的结果是不同的。
在ghci中,使用HsOpenSSL,加密结果为\GS\n\197:
import OpenSSL
import OpenSSL.EVP.Cipher
import Data.Maybe
method <- fmap fromJust $ withOpenSSL $ getCipherByName "bf-cfb"
cipher method "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f\x72" "\xcc\x88\xa5\x26\x85\xaf\x7f\x8d" Encrypt "abcd"
在python中,加密结果为K\x10<Q
import M2Crypto
M2Crypto.EVP.Cipher("bf_cfb", "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f\x72", "\xcc\x88\xa5\x26\x85\xaf\x7f\x8d", 1).update("abcd")
在shell中, abcd.txt 包含字符串“abcd”, abcd.bin 在vim中显示为K^P<Q}
openssl bf-cfb -in abcd.txt -out abcd.bin -pass pass:abc -K 900150983cd24fb0d6963f7d28e17f72 -iv cc88a52685af7f8d -nosalt
我假设M2Crypto结果等同于命令行结果,为什么HsOpenSSL结果不同?