alist-proxy/obfuscate.js
2024-10-15 18:57:56 +08:00

22 lines
860 B
JavaScript

const fs = require('fs');
const JavaScriptObfuscator = require('javascript-obfuscator');
const inputFilePath = './source.js'; // 替换为你的文件名
const outputFilePath = './index.js';
const code = fs.readFileSync(inputFilePath, 'utf8');
const obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
compact: true, // 压缩代码
controlFlowFlattening: true, // 控制流混淆
deadCodeInjection: true, // 死代码注入
numbersToExpressions: true, // 将数字转换为表达式
renameGlobals: true, // 重命名全局变量
simplify: true, // 简化代码
splitStrings: true, // 将字符串拆分为多个字符串
stringArray: true, // 将字符串转换为数组
}).getObfuscatedCode();
fs.writeFileSync(outputFilePath, obfuscatedCode);
console.log('Code has been obfuscated and saved to', outputFilePath);