What is Obfuscation?
“The obfuscator is free and open-source which is written in TypeScript and it’s BSD-2-Clause licensed. You can see an online implementation of the module in many places online. You can get more information about the library in the official Github repository,” says Tina Getzky, a tech writer at Australia2Write and NextCoursework.
How To Use the Obfuscator
The logic of this is very simple – obfuscating some piece of code with the module. You can create an instance of the module and then from that, you can obfuscate the method that will expect the first argument of code that you want to deal with and obfuscate.
This method returns what was obfuscated synchronously and through a series of variable/functions/arguments renaming and then the removing of the strings. Your source code will be transformed into something that is unreadable for other people and you as well but it will still work in the same way as it did before.
Here’s an example:
// Obfuscate the code providen as first argument
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;
// Display obfuscated result
You can also customize the obfuscator by passing the following arguments in the constructor.
You may also want to read the documentation in the library because the new options can appear. The repository can offer the presets and this can provide different feeling of different obfuscation levels. There is a special combination of options here as well. The better the obfuscation is, the slower this step is.
Here’s an example of a high obfuscation:
It’s almost impossible to recover the original source code from the version that was obfuscated. However, if a person who takes your obfuscated code has enough time and invests a lot of effort, knowledge, and patience in extracting the original code from this, they can reverse-engineer it which wouldn’t be a huge problem for them.
You can do a custom obfuscation as well and provide a configuration object.
Michael Dehoyos is a web developer at Phd Kingdom and Academic brits. He assists companies in their marketing strategy concepts and contributes to numerous sites and publications. Also, he is a writer at Origin Writings, academic service.