I've got Java web app and I want to obfuscate some JS code on server.
Now I've got site, where I can paste my JS code and obfuscate it manually e.g.
alert(1);
'Button press'
The site uses obfuscation from:
https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js
and this script obfuscates my code:
var obfuscationResult = JavaScriptObfuscator.obfuscate(
jsCodeToObfuscate,
{
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,
shuffleStringArray: true,
splitStrings: true,
splitStringsChunkLength: 5,
stringArray: true,
stringArrayEncoding: 'rc4',
stringArrayThreshold: 1,
transformObjectKeys: true,
unicodeEscapeSequence: false
});
and I've got my result.
I need to run obfuscation in backend. This method in Java should call javascript and return obfuscation result inside server.
I know, that using javascript in Java is possible, but I don't know how to use obfuscation function from the link in Java.
Is it possible to obfuscate my code on java server? Maybe there is any free api to make it and avoid to make it by myself?