Document the project structure and setup while excluding local dependencies and IDE settings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
const JSEncrypt = require("jsencrypt");
|
|
var crypto_js = require("crypto-js");
|
|
|
|
const encrypt = new JSEncrypt();
|
|
var paramPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvxXa98E1uWXnBzXkS2yHUfnBM6n3PCwLdfIox03T91joBvjtoDqiQ5x3tTOfpHs3LtiqMMEafls6b0YWtgB1dse1W5m+FpeusVkCOkQxB4SZDH6tuerIknnmB/Hsq5wgEkIvO5Pff9biig6AyoAkdWpSek/1/B7zYIepYY0lxKQIDAQAB";
|
|
encrypt.setPublicKey(paramPublicKey);
|
|
|
|
function MD5(text) {
|
|
return crypto_js.MD5(text).toString();
|
|
}
|
|
|
|
function getUuid() {
|
|
var s = [];
|
|
var hexDigits = "0123456789abcdef";
|
|
for (var i = 0; i < 32; i++) {
|
|
s[i] = hexDigits.substr(Math.floor(Math.random() * 16), 1)
|
|
}
|
|
s[14] = "4";
|
|
s[19] = hexDigits.substr(s[19] & 3 | 8, 1);
|
|
s[8] = s[13] = s[18] = s[23];
|
|
var uuid = s.join("");
|
|
return uuid
|
|
}
|
|
|
|
function beforeSend(page) {
|
|
var timestamp = Date.parse(new Date);
|
|
var requestId = getUuid();
|
|
|
|
var data = `{"limit":"20","page":"${page}"}`
|
|
const sign = MD5(data + requestId + timestamp)
|
|
return {
|
|
timestamp: timestamp,
|
|
requestId: requestId,
|
|
sign: sign,
|
|
data: encrypt.encrypt(data)
|
|
};
|
|
}
|
|
|
|
|
|
function aes_decrypt(encrypt_data) {
|
|
var key = crypto_js.enc.Utf8.parse("C8EB5514AF5ADDB94B2207B08C66601C");
|
|
var iv = crypto_js.enc.Utf8.parse("55DD79C6F04E1A67");
|
|
var decrypted = crypto_js.AES.decrypt(encrypt_data, key, {
|
|
iv: iv,
|
|
mode: crypto_js.mode.CBC,
|
|
padding: crypto_js.pad.Pkcs7,
|
|
})
|
|
return decrypted.toString(crypto_js.enc.Utf8);
|
|
}
|
|
|
|
// console.log(beforeSend(1));
|