How can I use any one of the following obfuscators to build an app
just follow the author instructions:
Installation WEBPACK
Install the package with NPM and add it to your devDependencies:
npm install --save-dev webpack-obfuscator
Usage:
var JavaScriptObfuscator = require(‘webpack-obfuscator’); // … // webpack plugins array plugins: [ new JavaScriptObfuscator ({ rotateUnicodeArray: true }, [‘excluded_bundle_name.js’]) ],
Or:
Installation BROWSER
Using Yarn or NPM
Install the package with Yarn or NPM and add it to your dependencies or devDependencies:
$ yarn add --dev javascript-obfuscator
Installation
$ npm install --save-dev javascript-obfuscator
In a Browser
From CDN:
<script src="https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js"></script>
From node_modules:
<script src="./node_modules/javascript-obfuscator/dist/index.browser.js"></script>
Usage
var JavaScriptObfuscator = require(‘javascript-obfuscator’);
var obfuscationResult = JavaScriptObfuscator.obfuscate(
(function(){ var variable1 = '5' - 3; var variable2 = '5' + 3; var variable3 = '5' + - '2'; var variable4 = ['10','10','10','10','10'].map(parseInt); var variable5 = 'foo ' + 1 + 1; console.log(variable1); console.log(variable2); console.log(variable3); console.log(variable4); console.log(variable5); })();
,
{
compact: false,
controlFlowFlattening: true
}
);
console.log(obfuscationResult.getObfuscatedCode());
Why do you need to obfuscate the code?
just look at the result:
console.log(obfuscationResult.getObfuscatedCode());
/*
var _0x2218 = [
'8|3|1|2|0|4|6|9|7|5',
'bqndd',
'dySIh',
'kTiiG',
'log',
'tuvgv'
];
(function (_0x38b423, _0x1d6bd4) {
var _0x39a849 = function (_0x5794c7) {
while (--_0x5794c7) {
_0x38b423['push'](_0x38b423['shift']());
}
};
_0x39a849(++_0x1d6bd4);
}(_0x2218, 0x114));
var _0x8221 = function (_0xcac13e, _0x3627d7) {
_0xcac13e = _0xcac13e - 0x0;
var _0x1eae4d = _0x2218[_0xcac13e];
return _0x1eae4d;
};
if you have the time or need to read the code you can, i think there is no magic solution to make js code not readable by the user. you can use ssr and just return the rendered html if you dont want some specific js logic in the front…
Sir,
I did not mean what you have suggested. What you have explained is already there in the documentation. But have you ever tried using it to obfuscator
the F7 cordova app code. I have tried it in so many different ways but it did not seems to be working. So what I mean is “How it can be used with framework 7-vue-webpack bundle”?