MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / encryptPayload

Function encryptPayload

wxapp/nice.js:74–84  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

72}
73
74function encryptPayload(data) {
75 const t = Math.floor(Date.now() / 1000);
76 const date = formatDateTime(t);
77 const key = Buffer.from(md5(ENCRYPT_SALT + date + t).substring(8, 24));
78 const iv = Buffer.from(md5(date + t + ENCRYPT_SALT).substring(8, 24));
79 const cipher = crypto.createCipheriv("aes-128-cbc", key, iv);
80 cipher.setAutoPadding(false);
81 const input = zeroPad(Buffer.from(JSON.stringify(data), "utf8"));
82 const encode = Buffer.concat([cipher.update(input), cipher.final()]).toString("base64");
83 return { encode, t, bd: BRAND_ID };
84}
85
86function isTokenError(message) {
87 return /40313|40317|unlogin|token|登录|授权|invalid/i.test(String(message || ""));

Callers 1

requestMethod · 0.85

Calls 3

formatDateTimeFunction · 0.85
zeroPadFunction · 0.85
md5Function · 0.70

Tested by

no test coverage detected