接口验签处理(2)
使用python处理验签接口:
import requests
import time
#10位时间戳:
timestamp=str(int(round(time.time())))
#none:13位时间戳:
nonce=str(int(round(time.time() * 1000)))
#token:
token='111111111111'
#passid:
passid='2222222222'
#签名:
import hashlib
#拼接并加密:
value=timestamp+token+nonce+timestamp
hsobj = hashlib.sha256()
hsobj.update(value.encode("utf-8"))
sha_256=hsobj.hexdigest().upper()
#发送请求:
url = "https://riotest.scdsjzx.cn/ebus/tfcodeserver/manageHighRiskArea/v1/listManageHighRiskArea"
payload={}
headers = {
'Content-Type': 'application/json;charset=utf-8',
'x-tif-paasid': passid,
'x-tif-timestamp': timestamp,
'x-tif-nonce': nonce,
'x-tif-signature': sha_256
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

浙公网安备 33010602011771号