From e9f2a55ceb7a1ce3cfdb5c2ef8fbfd766188b0a5 Mon Sep 17 00:00:00 2001 From: Hmily <114978440+ihmily@users.noreply.github.com> Date: Thu, 28 Aug 2025 17:08:15 +0800 Subject: [PATCH] feat: add laixiu sign js (#1195) --- src/javascript/laixiu.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/javascript/laixiu.js diff --git a/src/javascript/laixiu.js b/src/javascript/laixiu.js new file mode 100644 index 0000000..80982c6 --- /dev/null +++ b/src/javascript/laixiu.js @@ -0,0 +1,33 @@ + +function generateUUID() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); +} + +function calculateSign() { + const a = new Date().getTime(); + const s = generateUUID().replace(/-/g, ""); + const u = 'kk792f28d6ff1f34ec702c08626d454b39pro'; + + const input = "web" + s + a + u; + + const hash = CryptoJS.MD5(input).toString(); + + return { + timestamp: a, + imei: s, + requestId: hash, + inputString: input + }; +} + +function sign(cryptoJSPath) { + CryptoJS = require(cryptoJSPath); + return calculateSign(); +} + +module.exports = { + sign + }; \ No newline at end of file