// Method 1 - Promise
const tf = require("terserflow") // https://www.npmjs.com/package/terserflow
let codeToBeObfuscated = `function printMsg(msg) {console.log("This is a message from the obfuscated printMsg function : " + msg)}`;
let extraSecurity = true; // This is passed into the obfuscate method below
let resolvedPromise =tf.obfuscate(codeToBeObfuscated, extraSecurity);
// extraSecurity is optional and false by default ^^^^^^
resolvedPromise.then((obfuscated) => {
console.log(obfuscated);
//Do whatever you want with the variable obfuscated here for example write it to a file
}).catch((error) => {console.error(error);});
Method 2 - async and await
// Method 2 - async and await
const tf = require("terserflow") // https://www.npmjs.com/package/terserflow
async function obfuscateAndDoSomething(code) {
let extraSecurity = true; // This is passed into the obfuscate method below
let obfuscated = await tf.obfuscate(code, extraSecurity);
// extraSecurity is optional and false by default ^^^^
console.log(obfuscated);
//Do whatever you want with the variable obfuscated here for example write it to a file
}
obfuscateAndDoSomething("alert('Help');");