商智headers中的加密参数,如果不加的话无法得到正确返回
由encrypt_data、secret_key、secret_index多个参数MD5加密后获取
如果直接调用页面中的JS,结果比较过程比较简单,但是要使用nodejs和crypto-js包
crypto-js和python中的MD5是可以互相转换的,例如下面两段代码的效果就是类似的
const CryptoJS = require('crypto-js');
// 原始字符串
const str = 'your-string-here';
// 使用 crypto-js 进行 MD5 加密
const hash = CryptoJS.MD5(str);
// 将十六进制字符串转换为字节串
const hashWordArray = CryptoJS.enc.Hex.parse(hash.toString());
// 转换为 Base64 编码
const base64Encoded = CryptoJS.enc.Base64.stringify(hashWordArray);
console.log(base64Encoded);
import hashlib
import base64
# 原始字符串
str = 'your-string-here'
# 使用 hashlib 进行 MD5 加密
hash = hashlib.md5(str.encode('utf-8')).hexdigest()
# 将十六进制字符串转换为字节串
hash_bytes = bytes.fromhex(hash)
# 转换为 Base64 编码
base64_encoded = base64.b64encode(hash_bytes).decode('utf-8')
print(base64_encoded)
之所以说结构类似,是因为base64编码之后还是会有比较小的区别,如果用python中自带的MD5,需要把结果中的+和-替换掉