output.write(str(len(encrypted_secret_key)) + '\n')
output.write(encrypted_secret_key)
iv = '\x00' * 16
aes_engine = AES.new(secret_key, AES.MODE_CBC, iv)
output.write(aes_engine.encrypt(input.read()))
Encrypting a file with RSA in Python