# JAPHs and other fun with obfuscation

I like recreational obfuscation. Not that I'm really good at it, but here are some examples of what I wrote during inspiration attacks.

### Christmas tree 2.0

#!/usr/bin/env python3 m = ['\0', '\0', '\\', '/', '|', '\n', '*', ' '] n=1427204133903092885193970416731911941327299733 Y = lambda f : lambda x, y : f( Y( f ) ) (x, y) s = Y( lambda f : lambda x, y : y if not x else f(x >> 3, y + m[x & 7]))(n, "") ; print(s[::-1])

Should print an ASCII christmas tree:

* /|\ //|\\ ///|\\\ ////|\\\\

...eight years later. Another take on the custom ASCII art encoding theme, this time
every character is encoded by three bits. Since we only need six characters, while
three bits can encode 2^{3}=8 distinct values, two unused values are mapped
to the null character. A loop would be too obvious, so I used recursion with accumulator,
implemented using the Y combinator instead of a direct recursive definition.

Date: December 2018

### Fermat numbers

#!/usr/bin/env perl s3:n(q{Just });s5:n("another ");s17:n(q{Perl });s257:n("hacker"); s65537:n("\n");$p=1;sub n{$p++; $w=2**(2**$p)+1;print@_;goto"s$w" unless grep/^1$/,map{1 if $w%$_==0}(2..int(sqrt($w)));exit;};n;1;

Should print “Just another Perl hacker”. Labels contain Fermat numbers, the n() subroutine generates a Fermat number and jumps to its label as long as the next number after it is prime. Since only the first five are prime, it terminates as expected.

The primality test is awfully inefficient but for very small numbers it doesn't matter.

Date: some 2013 I guess.

### Email is the key

#!/usr/bin/env perl @a=split(//, "daniil @ baturin . org" ); # Daniil Baturin @b=split(//,q/Px%!+o0Q6lh*7dp$.@8#t!nr/);while($i<24){$_.= chr((ord(@b[$i])-ord(@a[$i])+62)%94+32);$i++};print"$_\n"#

Should print traditional “Just another Perl hacker”.

The idea was to make the email address an essential part of the program that cannot be modified without understanding.

So the email address was used as a key for the running key variant (that is, where the key length is equal to the plaintext length) of the Vigenere cipher that uses the entire printable ASCII range as its alphabet.

Date: late 2012.

### Three primes

#!/usr/bin/env perl use bigint;$i= 8311 * 11506699 * 5456897772732206286791603681159406921396401 ;while($i){$_.=chr($i&0x7f);$i>>=7;}print

Should print traditional “Just another Perl hacker”.

Simply obtains character codes from the string converted to number and then factorized.

Date: September 2012

### Seven points of Python

#!/usr/bin/python from math import log, exp print ("".join(map(lambda x:chr((int((round((29*exp ((log(x)*6))/720-(283*exp (log(x)*5))/240+(1657*exp (log(x)*4))/144-(2209*exp (log(x)*3))/48+(21403*exp (log(x)*2))/360+(231*x)/5 +10.4)))))),range(1,7))))

Should print “Python”. Last I checked, it works with either Python 2.7 or Python 3.

The function that produces the ASCII codes of the “Python\n” string was constructed with Lagrange polynomial interpolation.

Date: October 2012

### Perl is in my heart (or vice versa)

#!/usr/bin/env perl use bigint;$h=0x3eff8fe0f0047c5fd; while($h){$_.=$h&1?' ':'*';$h/=2}; $_=join("\n",$_=~/.{11}/g);print;1

Should print an ASCII heart:

* * *** *** ********* ***** *** *

Obviously, written for Feb 14th. Specifically, for a valentines day contest my ISP once held where users submitted their postcards, videos, and the like. To their credit, they ran it in some test VM and posted a screenshot of the terminal.

Spaces are encoded with zeroes and stars with 1's, packed into a single hexadecimal number.

Date: February 2012 perhaps?

### Glider

#!/usr/bin/env perl @glider= ([ 0, 1, 0 ], [ 0, 0, 1 ], [ 1, 1, 1 ]); @hacker= ([ 3.00, 3.00, 2.45 ], [ 4.00, 2.90, 2.85 ], [ 4.00, 2.90, 2.88 ], [ 3.90, 3.80, 2.95 ], [ 3.90, 3.60, 2.85 ], [ 4.00, 3.95, 3.04 ], [ 1.00, 1.00, 0.95 ]); sub mul(\@\@){@r=();for($i=0;$i<3;$i++){for($j=0;$j<3;$j++){;$r [$i]+=$_[0][$i][$j]*$_[1][$i]}}return\@r}sub ip(\@){$w=0;for($k =0;$k<3;$k++){$w+=$_[0][$k]*$_[0][$k];}return chr(int($w));}for ($n=0;$n<=6;$n++){$_.=ip(@{mul(@glider,@{$hacker[$n]})});}print

I generally support Eric Raymond's idea to use the glider as technology neutral hacker subculture emblem (even if I don't agree with a lot of his opinions).

Here the glider is represented as a 3x3 matrix and the ASCII codes or the “Hacker” word characters are calculated as (squares of) euclidian norms of constructed vectors after applying the glider operator matrix to them.

Date: November 2012

### Christmas tree

#!/usr/bin/perl $_=16;$j=1;$r.=chr($_*2)x($_+1)."*"."\n";for ($i=$_;$i>$_>>1;$i--){;$r.=chr(2*$_)x$i.chr( $_*3-1)x$j.chr($_*($_>>1)-sqrt($_)).chr($_*6 -sqrt($_))x$j.chr($_-6);$j++}$l=@a;print($r)

Early attempt, written in the late 2010 for the winter holidays.