Obfuscating things can be incredibly fun:
http://keyboardfire.com/ | license: MIT | contact/email: andy@<website> | enjoy!
(U=function(o){this.Q=o}).prototype.w=function(M){J='ns',H=Math.PI,G='.',T=H|0+G
E=function(b){return b.replace(Q[T],function(b){return h(b.charCodeAt()-H+T)})};
return-M,(l=this.Q)+Array(T).join((h=l.constructor.fromCharCode)(0x79+U.length))
};function F(){}g=((B=function(){return[].slice.call(arguments).join('o')}),F)//
function C(r,p,C){return eval(x="while(p=((p\x7c1744円)-1))C=(C?(C+r)\x3a''+r)")}
Y=C(),(b=new U(g.name+C(x[x=2],-(~-[]*x)))).w();Y=Y.slice(4,7);F.L=25*+([]+H)[T]
f=new U(371..toString(31,Y).replace(/./,function(x){return x.toUpperCase()}));{}
for(i=s=0;i++<F.L;s=Array(+'')+[]){Q=['le','hm',['%',T+74],new RegExp(G,'g',J)];
if(!(i%Y.length))s+=b[unescape(Q[2].join(''))]();i%x.indexOf('(')||Y[[]]||(s+=f.
w());eval(B('c',J,Q[0]))[E(Q[1]).split('').reverse().join(h(C(1)))](s||U.g||i);}
It'd be nice if we could have obfuscation challenges here on PPCG. However, there are a few problems that would arise:
First and most obviously, it'd be incredibly difficult to provide an objective winning criterion. "Obfuscated <this task> popularity-contest" can only go so far.
Obfuscated code may be malicious, and dangerous to test. This can be partially mitigated by including a "timeline" (like a revision history) that shows the code getting more and more obfuscated, but a sneaky coder could still slip something through. (I promise the example snippet above is safe ;) )
Could we figure out a way to solve these problems, or do we just have to enjoy obfuscating on our own, independently from PPCG? (Perhaps we could create a chatroom for obfuscation, if we can't think of a way to make obfuscation challenges fit the site.)
-
\$\begingroup\$ The example code looks more golfed than obfuscated. \$\endgroup\$Peter Taylor– Peter Taylor2014年10月20日 15:13:19 +00:00Commented Oct 20, 2014 at 15:13
-
7\$\begingroup\$ @PeterTaylor I'm pretty sure FizzBuzz can be shorter than that. ;) \$\endgroup\$Doorknob– Doorknob Mod2014年10月20日 16:53:27 +00:00Commented Oct 20, 2014 at 16:53
2 Answers 2
Well, we do have obfuscation challenges:
-ENDED- Do something that looks like something else
A code challenge with an objective winning criterion.
-
An implement one of four tasks popcon.
Sort a list and write some English!
Obfuscattion should result in code looking like a business letter.
Lockers vs. Crackers: The Five-Element Sequence
cops-and-robbers, which combines quite nicely with obfuscation.
Cops and Robbers: Reverse Regex Golf
As before, but got
(削除) electrolytes (削除ここまで)regexes.
All of the above are fine in my opinion, although a question would have to be quite different from the existing ones to be interesting.
Generic code obfuscation is a lot like code trolling: It's fun the first two or three times, but all subsequent challenges are essentially duplicates.
-
6\$\begingroup\$ Most of the questions tagged underhanded are also about obfuscation. \$\endgroup\$Peter Taylor– Peter Taylor2014年10月20日 15:12:24 +00:00Commented Oct 20, 2014 at 15:12
It's not impossible to find an objective winning criterion other than popularity-contest.
You could design or find an algorithm which compares the code to its intended output, or to an unobfuscated program which does the same thing. If we used something simple such as Levenshtein edit distance, then the code which is furthest from the intended output or the unobfuscated sample program would win.
The problem with something as simple as Levenshtein distance is that it doesn't take into account many obfuscation techniques. Suppose that I had to write an obfuscated program that outputs "hello world". In CJam, I could write "ifmmp!xpsme"{(}% (try it here).
If we scored by Levenshtein distance from hello world, this program would score many points. It isn't very obfuscated however:
"ifmmp!xpsme"- place the stringifmmp!xpsmeonto the stack{(}%- treating the string as an array of characters, carry out the(operation (decrement) on each element- Every character in the string is replaced by the one which precedes it in ASCII. The result is that the string
hello worldis now on the stack. - At the end of the program, the contents of the stack are printed to standard output.
We need a better algorithm, and I'm not sure that one exists - we could make one ourselves. It would have to take into account Levenshtein distance, simple ASCII shifts like the one I used, and other things. It would be quite hard but not impossible to prepare an official program that calculated the "obfuscation distance" between two strings.
There would, inevitably, be loopholes in the algorithm which people will exploit - so we would have to keep updating the scoring system. Questions might need to be bound to a specific version of the algorithm to avoid having to recalculate scores every time it is updated ("Your score is the obfuscation distance between your program and the output string, according to Obfuscounter 0.8.5. Even if a later version is released, your entry is scored by version 0.8.5.").