javascript-obfuscator是一个免费的JavaScript代码混淆工具,它功能强大,可以把你的源代码变得“面目全非”,完全没有可读性。还具有部分防调试功能,给JavaScript代码多一层保护。
1,安装
npm install javascript-obfuscator -g
2,查看版本
javascript-obfuscator -v
3,具体使用
javascript-obfuscator a.js --config config.json --output b.js
a.json 原文件 b.json 输出文件 config.json obfuscator配置文件
配置大概内容:
{
"compact": true,
"controlFlowFlattening": true,
"controlFlowFlatteningThreshold": 0.75,
"deadCodeInjection": true,
"deadCodeInjectionThreshold": 0.4,
"debugProtection": false,
"debugProtectionInterval": false,
"disableConsoleOutput": true,
"identifierNamesGenerator": "hexadecimal",
"log": false,
"renameGlobals": false,
"rotateStringArray": true,
"selfDefending": true,
"stringArray": true,
"stringArrayEncoding": "base64",
"stringArrayThreshold": 0.75,
"unicodeEscapeSequence": false
}
最后附上官网地址:https://github.com/javascript-obfuscator/javascript-obfuscator查看具体使用方式