Skip to content

johnhaggkvist/WATifyJS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WATify.js

Inspired by the answer in this thread. I got the idea of having a WATifyer that obfuscates JavaScript.

The idea is based on the fact that EcmaScript accepts most unicode characters in variable names.

Utilizing that there are a couple of characters in the Cyrillic range that look the same as Latin characters when using a lot of fonts one can construct two valid variable names that look the same in a font, but consists of different characters and therefore are different identifier.

So, I forked UglifyJS 2 (that is perfectly capable of minifying variable names while not breaking the code). Wrote an algorithm that outputs similar looking words, took a name that has a lot of exchangeable characters (BOOMBOX), and pushed play. :)

The results are:

My original JavaScript (readable, outputs the area 10 times).

$ cat demo.js 
;(function () {
  var calculateSquareArea = function (width, height) { return width * height },
      height = 100,
      width = 200,
      area = calculateSquareArea(width, height),
      numberOfTimesToPrintResult = 10,
      i = 0;

  for (; i < numberOfTimesToPrintResult; i++) {
    console.log(area);
  }
})();

Way too readable! Enter WATify!

$ ./bin/uglifyjs demo.js -b -m
(function() {
    var ВООМВОХ = function(ВООМВОХ, ВООМВОX) {
        return ВООМВОХ * ВООМВОX;
    }, ВООМВОX = 100, ВООМВOХ = 200, ВООМВOX = ВООМВОХ(ВООМВOХ, ВООМВОX), ВООМBОХ = 10, ВООМBОX = 0;
    for (;ВООМBОX < ВООМBОХ; ВООМBОX++) {
        console.log(ВООМВOX);
    }
})();

Now thats more like it! This is still valid JavaScript and will run in you console, still outputs the area 10 times.

About

JavaScript parser / mangler / compressor / beautifier toolkit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%