How to obfuscate variable names in JavaScript?

I am an artist who wrote a simple game in Javascript. Yah! But I don't care, because I'm bruised like a peach! I study the complexity of cheating in a game. So obfuscating code will make it harder to cheat, right? Difficult, not impossible. I understand this and could accidentally open a can of worms here ...

Essentially, I'm looking for an online tool that renames variables; and don’t say search and replace in the text bar :). For example, using http://packer.50x.eu/ in one line of code

var loopCounter = 0; 

we get the result:

 eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1 2=0;',3,3,'|var|loopCounter'.split('|'),0,{})) 

The above looks like a mess, and that's great; but it’s pretty easy to highlight English words like loopCounter. I would expect this to cause the variable names to become obscure (words with a single letter without nouns?), Very similar or should have been my task anyway as part of writing the code. Or is it a waste of time trying to make variable names since the variable declaration is preceded by var, and therefore it makes no sense to mask it?

+4
source share
3 answers

After a lot of searching (and the links to above) I found this that allows obfuscation of string variables. And that is what I was.

+2
source

Several online tools are available for this: the javascript compressor , and then theres the javascript minifier , which can also be used for large images. otherwise you could just use some offline tools, sure they are easy to find

0
source

You can use Javascript Obfuscator ... your code will be very difficult to decode!

Hope this helps! ^ _ ^

0
source

Source: https://habr.com/ru/post/1494458/


All Articles