function jiami(e, t, i) {
i || (i = 100 + Math.floor(900 * Math.random()));
var o = e + 100 + i,
a = hex_md5(o + id + t).toString();
return "t" + (a.charAt(17) + a.charAt(3) + a.charAt(27) + a.charAt(11) + a.charAt(23)) + i + e;
}
分析一下 jiami(990000,'money',123) 给money这个key加密value值为990000 加三位随机数返回加密后字符串 格式是这样的tabcde123990000
const AnyProxy = require('anyproxy');
var tmoney, tstar, pmoney, gk, xj, jnw;
const options = {
port: 8001,
rule: {
summary: 'Rule to modify request data',
* beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url.indexOf('downloadRecord') != -1) {
var newResponse = Object.assign({}, responseDetail.response)
var str = newResponse.body.toString();
var all = JSON.parse(str);
var re = JSON.parse(all.record);
var id = JSON.parse(re.openid).openid;
var rere = JSON.parse(re.recordItemBag);
function jiami(e, t, i) {
i || (i = 100 + Math.floor(900 * Math.random()));
var o = e + 100 + i,
a = hex_md5(o + id + t).toString();
return "t" + (a.charAt(17) + a.charAt(3) + a.charAt(27) + a.charAt(11) + a.charAt(23)) + i + e;
}
try {
if (tmoney != 0) {
re.money= jiami(parseInt(tmoney), 'money');
}
} catch (err) { };//修改鱼干
try {
if (tstar != 0) {
re.star = jiami(parseInt(tstar), 'star');
}
} catch (err) { };//修改星星
try {
if (pmoney != 0) {
re.money_plate = jiami(parseInt(pmoney), 'money_plate');
}
} catch (err) { };//修改盘子
all.record = JSON.stringify(re);
newResponse.body = JSON.stringify(all);
return { response: newResponse };
}
}
},
webInterface: {
enable: true,
webPort: 8002
},
throttle: 10000,
forceProxyHttps: true,
wsIntercept: false,
silent: false
};
const proxyServer = new AnyProxy.ProxyServer(options);
proxyServer.start();