Obfuscate JS Code - Demo
I have added this JS file reference to this HTML page and called the valid email address function. If the email address is valid, then I’m logging that message in the console. If the email is invalid, then we will get this (Invalid Email Address) message and if the email is valid, then we’ll get this (Valid Email Address) message.
We need to write this (obfuscateResult) variable content into a separate JS file. That’s our newly generated JS filename: fs.writeFile(’./CommonOperation.Obfuscated.js). Then we get the obfuscated code from this (obfuscateResult) variable. Then define the callback function. Our code is ready and it’s time to run the code.
Again open the Terminal and write the command (node obfuscateUtil.js) then press enter. You can see that we are successfully able to generate our newly obfuscated JS file. Open the JS file, you can see the newly generated obfuscated file is really hard to read and interpret. But this is a totally valid code.