From bc4c5c5df67a0a08aaca90ca2d7bb27ae2b8cf11 Mon Sep 17 00:00:00 2001 From: luzhisheng Date: Wed, 10 Jul 2024 10:36:39 +0800 Subject: [PATCH] =?UTF-8?q?fastmoss=20Fm-Sign=E5=8A=A0=E5=AF=86=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=A0=B4=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastmoss/test.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 fastmoss/test.js diff --git a/fastmoss/test.js b/fastmoss/test.js new file mode 100644 index 0000000..162c4a9 --- /dev/null +++ b/fastmoss/test.js @@ -0,0 +1,36 @@ +const crypto = require('crypto'); + +function encryptMD5(data) { + const hash = crypto.createHash('md5'); + hash.update(data); + return hash.digest('hex'); +} + +function encryptParams(g) { + var O = { + "salt": "asjdfoaur3ur829322" + } + , X = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "" + , J = Object.keys(g).sort() + , me = ""; + J.forEach(function (Rn) { + me += Rn + g[Rn] + O.salt + }); + + for (var Ce = encryptMD5(me + X), Ze = "", Sn = 0, Ke = Ce.length - 1; Sn < Ce.length && !(Sn >= Ke); Sn++, + Ke--) + Ze += (parseInt(Ce[Sn], 16) ^ parseInt(Ce[Ke], 16)).toString(16); + var dn = Ze + Ce.substring(Sn); + return dn +} + + +g = { + "_time": 1720545957, // Math.floor(Date.now() / 1000) 时间戳 + "cnonce": 53701680 // Math.floor(10000000 + Math.random() * 90000000) 随机数 +}; + +da = ''; // 有点接口是带d加盐的{"type":{"headers":{"lang":"ZH_CN"}}} + +console.log(encryptParams(g, da)); +