$ echo 'this is text' > text.1
$ openssl enc -aes-256-cbc -a -k "thisisapassword" -in text.1 -out text.enc
$ openssl enc -d -aes-256-cbc -a -k "thisisapassword" -in text.enc -out text.2
$ cat text.2
this is text
我可以用 openssl 做到这一点。现在,我如何在 m2crypto 中做同样的事情。文档缺少这一点。我查看了 snv 测试用例,仍然没有。我找到了一个示例,http ://passingcuriosity.com/2009/aes-encryption-in-python-with-m2crypto/(更改为 aes_256_cbc),它会加密/解密它自己的字符串,但它不能解密任何用openssl,它加密的任何东西都不能从 openssl 解密。
我需要能够使用 aes-256-cbc 进行 enc/dec 解码,因为许多文件已经用它加密,我们还有许多其他系统也可以很好地处理 aes-256-cbc 输出。
我们只使用密码短语,没有 IV。所以将 IV 设置为 \0 * 16 是有道理的,但我不确定这是否也是问题的一部分。
有人有任何与 m2crypto 兼容的 AES 256 工作样本吗?
我还将尝试一些额外的库,看看它们是否能更好地工作。