OpenSSL的不解密由pycrypto
加密我在Python加密文件中的文件:OpenSSL的不解密由pycrypto
from Crypto.Cipher import AES
from Crypto import Random
key = Random.new().read(16)
iv = Random.new().read(AES.block_size)
encryptor = AES.new(key, AES.MODE_CBC, iv)
with open(in_file, 'rb') as fin, open(out_file, 'wb') as fout:
fout.write(iv)
while True:
chunk = fin.read(16*1024)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += b' ' * (16 - len(chunk) % 16)
fout.write(encryptor.encrypt(chunk)
print base64.b32encode(key)
但是当以后有什么我尝试使用OpenSSL解密: openssl aes-256-cbc -d -in enc -out new.zip
返回袋幻数 什么,我做错了什么?
计划使用128位的AES密钥进行加密,从线看:
key = Random.new().read(16)
所以,而是采用
openssl aes-256-cbc -d -in enc -out new.zip
使用本
openssl aes-128-cbc -d -in enc -out new.zip
谢谢,但它没有帮助。我仍然得到'不可思议的数字'。 – nekolyanich 2013-03-20 06:56:59
也许问题是在密钥上应用b32encode? – nekolyanich 2013-03-20 06:59:40
你必须提供在命令行中使用的密钥和iv。 Kinldy检查这篇文章。 http://*.com/questions/8343894/aes-encrypt-with-openssl-command-line-tool-and-decrypt-in-java – 2013-03-20 07:02:48
的可能的复制[如何使用Python/PyCrypto以OpenSSL兼容的方式对文件进行AES加密/解密?](http://*.com/questions/16761458/how- to-aes-encrypt-decrypt-files-using-python-pycrypto-in-an-openssl-compatible) – Gregor 2015-11-01 05:19:57