Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

JAPH randomness

by awwaiid (Friar)
on Jan 30, 2005 at 06:52 UTC ( #426352=obfuscated: print w/replies, xml ) Need Help??

This one may not (will definately not?) run on all perl installations. I'm running mine on stock debian installs and it works, but YMMV. But it is fun anyway. If anyone likes I can provide the code I used to generate this, and then it can be re-created for any platform.

I would just like to add that the obfu's I do tend to be based on some concept or algorithm which is the heart of the thing... so I invite discussion on that or improvements on the snippet as a whole!

$"='314747"7"84561"12"277057"10"53708"12"2466"25"' ;sub _{$;.=chr(rand(24)+64)}while($"){srand$";$"=~ s/.*?"//;rand(24)for(1.."$\"");$"=~s/.*?"//;_()for (1..5)}$;=~y/BV/ ./;$;=~s/\w+/\u\L$&/g;print$;.$/

Replies are listed 'Best First'.
Re: JAPH randomness
by jdalbec (Deacon) on Jan 30, 2005 at 21:14 UTC
    It works fine on perl 5.8.1-RC3/Mac OS X 10.3/PPC G4 and perl 5.8.4/Debian Sarge/AMD K6 MMX, so endianness does not appear to be an issue. It fails on perl 5.6.1/Red Hat Linux 7.3/Intel 486DX because the string passed to srand() is not entirely numeric and therefore is interpreted as 0. The following modification works around this:
    $"='314747"7"84561"12"277057"10"53708"12"2466"25"'; sub _{$;.=chr(rand(24)+64)}while($"){$"=~s/(.*?)"// ;srand$1;rand(24)for(1.."$\"");$"=~s/.*?"//;_()for( 1..5)}$;=~y/BV/ ./;$;=~s/\w+/\u\L$&/g;print$;.$/

      Cool, thanks. I didn't even expect it to break because of that... It should really break (and require significant alteration of $') if someone were to use a perl which had a different rand() library call compiled in.

Re: JAPH randomness
by wolfger (Deacon) on Feb 01, 2005 at 14:11 UTC

    Looks like a great JAPH, but it doesn't work on my work laptop. I will try at home later.
    This is perl, v5.8.0 built for MSWin32-x86-multi-thread:

    ∟Nhsk.Mio Pnfowrkajfwfkwg

    Linux, sci-fi, and Nat Torkington, all at Penguicon 3.0
    perl -e 'print(map(chr,(0x4a,0x41,0x50,0x48,0xa)))'

      So the issue, as I mentioned previously, is whether your perl and my perl have the same random number generator. Heres one way to check:

      perl -e 'srand(0);print rand(100)."\n"'

      When I run this I get 17.082803610629. What do you get?

      Let us know if it works at home! :)

        I get 0.115966796875 on my laptop. I forgot to try at home.
        So let me get this straight... We can "initialize" the random number generator such that the numbers are not random whatsoever, but rather completely predictable? Very interesting.

        Linux, sci-fi, and Nat Torkington, all at Penguicon 3.0
        perl -e 'print(map(chr,(0x4a,0x41,0x50,0x48,0xa)))'

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://426352]
Approved by ysth
Front-paged by ysth
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2021-09-25 07:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found