Alok Menghrajani

Previously: security engineer at Square, co-author of HackLang, put the 's' in https at Facebook. Maker of CTFs.


This blog does not use any tracking cookies and does not serve any ads. Enjoy your anonymity; I have no idea who you are, where you came from, and where you are headed to. Let's dream of an Internet from times past.


Home | Contact me | Github | RSS feed | Consulting services | Tools & games

For the last few years, ioccc has been organizing obfuscated coding contests.

The goal is to write short programs in C, in a way that is essentially impossible to read.

One of my all time favorite contributor is Brian Westley, who has written amazing pieces of obfuscated code (and who has won the contest multiple times). One of his entries computes pi. The code is laid out in the shape of a circle and the program works by dividing the area of the code by the "radius" squared.

#define _ F-->00 || F-OO--;
long F=00,OO=00;
main(){F_OO();printf("%1.3f\n", 4.*-F/OO/OO);}F_OO()
{
            _-_-_-_
       _-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
       _-_-_-_-_-_-_-_-_
            _-_-_-_
}

Note: as you increase the circular pattern, you'll get a better approximation for the value of pi.

I don't think obfuscated code in JavaScript makes much sense, because it's trivial to encode a program as a string and just eval it.

I did like the idea of laying code in a circular pattern, so I wrote the following piece of JavaScript, which also computes pi:

       <html><body
    id="out"><script>
  setTimeout(function()
 {d = out.parentElement.
outerHTML.replace(/ /g,''
); area=d.length*2;radius
=d.split(/\n/).length;pi=
area / (radius * radius);
pi=(pi * 100 | 0 ) / 100;
 out.innerHTML="pi="+pi
  },1)</script></body>
     h4ck  by   Alok
         </html>

links