通过请求参数ASCII排序+密钥的md5加密方案
function secretToken(data) {
var obj = {};
var arr = [];
var token = '';
for (let i in data) {
arr.push(i)
}
//此处可换成Object.keys(data).sort()
arr.sort();
for (let x = 0; x < arr.length; x++) {
obj[arr[x]] = data[arr[x]]
};
for (let y in obj) {
if (token == '') {
token = token + y + '=' + obj[y] + '&';
} else {
token = token + y + '=' + obj[y];
}
};
token += secret_key;
obj['token'] = hex_md5(token);
return obj;
}