我在python中加密文件:
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
它返回包幻数我做错了什么?