转自:https://www.againfly.com/flytag_605.html
参考:https://blog.csdn.net/foupwang/article/details/103306332
官网:
https://www.npmjs.com/package/javascript-obfuscator
民间安装方式
npm init -f
npm install formidable --save
npm install -g javascript-obfuscator
官网安装方式
npm install --save-dev javascript-obfuscator
默认不用参数的加密直接执行也可以
javascript-obfuscator input.js --output output.js
使用部分自定义参数
--target 'browser-no-eval'
--disable-console-output true
--debug-protection true
--debug-protection-interval true
--identifier-names-generator 'hexadecimal'
--string-array true
--rotate-string-array true
--string-array-encoding 'rc4'
--string-array-threshold 0.8
更多的详细配置参数可以看官网
javascript-obfuscator 1.js --output 2.js --compact true --target 'browser-no-eval' --disable-console-output true --debug-protection true --debug-protection-interval true --identifier-names-generator 'hexadecimal' --string-array true --rotate-string-array true --string-array-encoding 'rc4' --string-array-threshold 0.8
{
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1,
debugProtection: true,
debugProtectionInterval: true,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
log: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: 'rc4',
stringArrayThreshold: 1,
transformObjectKeys: true,
unicodeEscapeSequence: false
}
{
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,
transformObjectKeys: true,
unicodeEscapeSequence: false
}
{
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
log: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: false,
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
}