python-3.x - Python加密request.post的问题
问题描述
我对加密的发布请求有疑问。加密算法是 AES/ECB/PKCS5Padding,API 设置在这里:https: //bondevalue.com/app/apiInstructions client_token 正在工作。但我总是收到“似乎您提供的输入数据无效。提供有效格式的数据。
import requests
import json
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import base64
client_token = b'ae3rncr14cngemft'
requestData = b'{\"data\":{\"userToken\":\"[ae3rncr14cngemft]\"},\"bondISINId\":\"[XS1401197253]\", \"fromDate\":\"[2016-12-07]\"}'
cipher1 = AES.new(client_token, AES.MODE_ECB)
requestEncrypted = str(base64.b64encode(cipher1.encrypt(pad(requestData, 16, 'pkcs7'))), 'utf-8')
url = 'https://bondevalue.com/app/bondDetailsHistoryData'
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {'requestData': requestEncrypted}
answer = requests.post(url=url, data=requestEncrypted, headers=headers)
response = answer.json()
解决方案
推荐阅读
- apache-spark - 如何在 spark-sql 中显示列标题
- ruby-on-rails - 在 Rails Forms 中,如何通过关联的主键而不是索引来键入嵌套关联?
- c# - 我是否需要在 WCF Web 服务中调用 URLDecode
- javascript - 从输入日期选择器发布接下来的几周或几个月 - HTML JavaScript
- c - 当我输入时加法程序崩溃
- xaml - UWPCommunityToolkit DropShadowPanel 防止网格拉伸
- javascript - 谷歌地图 infoWindow 按钮(离子)问题
- python - numpy nan 结果中没有 nan 值
- c# - 在 ScrollViewer - WPF 中绑定动态创建的控件
- c# - 多态结果的 JSON 反序列化