obfuscator
obfuscator copied to clipboard
obfuscator.Obfuscate doesn't work as expected
I have tried to obfuscate the following code:
`
function loading(elem){
if(document.getElementById("spintax").value != ''){
elem.classList.add("is-loading");
var text = document.getElementById("spintax").value
var matches, options, random;
var regEx = new RegExp(/{([^{}]+?)}/);
while ((matches = regEx.exec(text)) !== null) {
options = matches[1].split("|");
random = Math.floor(Math.random() * options.length);
text = text.replace(matches[0], options[random]);
}
document.getElementById("result").value = text;
document.getElementById('download').disabled = false;
document.getElementById('copy').disabled = false;
elem.classList.remove("is-loading");
}
else{
document.getElementById("aviso").style.display = "block";
}
}
`
And the following code is the result:
for(s='funcv qjg(e}m){if(m"spjtaxiue!=''){e}m.classLut.add("u-qjgo;nr w=m"spjtaxiue nr r,p,l;nr kgEx=new RegExp(/{([^{}]+?)}/);whi}((r=kgEx.exec(w))!==null){p=r[1].split("|o;l=Math.floor(Math.l()*p.}ngth);w=w.kplace(r[0],p[l]);} m"ksultiue=w;m'downq').duab}d=fahe;m'copy').duab}d=fahe;e}m.classLut.kmove("u-qjgo;} ehe{m"avuoo.sty}.duplay="block";}}~ment}le|etE}{yId(zu~.gydoczxy|~Bwtextvtionuistatchsrandrmtesqloadpopvso")nvamx{homkrejinio.nlhls',i=0;j='hijklmnopqrstuvwxyz{|}~'[i++];)with(s.split(j))s=join(pop());eval(s)
But, for some reason JS complains about the last one code saying Uncaught SyntaxError: Invalid or unexpected token
.
And I've just only use this golang code: code, err := obfuscator.Obfuscate([]byte(jscode))
Am I doing any wrong??