JSON对象 → POST发送接收 → JSON对象步骤1:构建JSON对象
↓
步骤2:转换为JSON字符串
↓
步骤3:RSA加密(使用公钥)
↓
步骤4:Base64编码
↓
步骤5:POST发送到服务器步骤1:接收响应数据
↓
步骤2:二进制解码(如果开启BinaryResponse)
↓
步骤3:Base64解码
↓
步骤4:RSA解密(使用公钥)
↓
步骤5:解析JSON对象
↓
步骤6:解密data字段(如果开启DataEncrypt)
↓
步骤7:验证签名(如果开启SignMode)
↓
步骤8:返回业务数据步骤1:收集所有参数(排除sign自身)
params = {
"card_code": "ABC123",
"device_code": "DEVICE_001",
"timestamp": 1699999999
}
步骤2:按key字母顺序排序
sortedKeys = ["card_code", "device_code", "timestamp"]
步骤3:拼接签名字符串
signString = "card_code=ABC123&device_code=DEVICE_001×tamp=1699999999&key=" + AppKey
步骤4:MD5计算签名(32位小写)
sign = MD5(signString)
// 结果示例:abc123def456789...
步骤5:添加sign到请求参数
params["sign"] = signkey=AppKeysignString = "data=" + response.data +
"&nonce=" + response.nonce +
"×tamp=" + response.timestamp +
"&key=" + AppKey
calculatedSign = MD5(signString)
验证: calculatedSign == response.signsignString = "data=" + response.data +
"&" + 请求参数(排除sign和timestamp) +
"&nonce=" + response.nonce +
"×tamp=" + response.timestamp +
"&key=" + AppKey
calculatedSign2 = MD5(signString)
验证: calculatedSign2 == response.sign2sign 不参与sign2计算timestamp 不参与sign2计算(使用响应的timestamp)T3网络验证https://www.t3yanzheng.com1. 验证魔术头(约42字节)
2. XOR解混淆(使用AppKey的MD5作为密钥)
3. 得到加密数据
4. 继续RSA解密流程