### A Simple JAPH

by Athanasius (Chancellor)
 on May 07, 2012 at 16:02 UTC Need Help??

My first effort:

```\$_='penflillggplmhlllpkolhmhgiokmpmhkegopckdlmlckemhge';
tr/g-p/0-9/;my@x=map{-84+hex\$_}\$_=~/[A-F0-9]{2}/gi;my@y=
shift@x;push@y,\$_+\$y[-1]for@x;print join'',map{chr\$_}@y;
“...an ill-favoured thing, sir, but mine own.” —As You Like It (Act 5, Scene 4)

Regards,

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re: A Simple JAPH
by ambrus (Abbot) on May 07, 2012 at 21:09 UTC

This obfu is nice because it's hard to see at first what it will print. Allow me a few minor comments though. (I'll use spoiler tags to not spoil anything for readers who hasn't decoded the obfu yet.)

Let me list some specific good points of this obfu too.

You're not using unpack"C*",pack"H*",\$_ to decode the string of hexadecimals. That would be both longer than the map{hex}/\w./g you're using and easily recognizable for seasoned obfuscation readers.

Secondly, you put the -84 constant together with the hex instead of in the \$_+\$y[-1], thus making its meaning more difficult to see. As your code is now, I first see the -84 term, and don't understand what it's doing until later when I see that the numbers are used as differences which is why you want negative numbers.

Thirdly, you wrote the code as separate statements each doing one step of the computation. This seems actually seems to suit this obfu more than a traditional terse style where you'd write everything in one statement, such as

```y/g-z/0-9/,print chr(\$_y+=-84+hex)for"penflillggpl
mhlllpkolhmhgiokmpmhkegopckdlmlckemhgeji"=~/\w./g;
as the separate statements put the related operations far away from each other, thus making the code less readable, but still short enough.

(Ps. Modifying the above to use the y///r switch thus making the statement even more readable is homework for reader.)

Wow! Thank-you ambrus for such detailed feedback.

Taking (most of) your comments on board, the JAPH now looks like this:

```\$_='penflillggplmhlllpkolhmhgiokmpmhkegopckdlmlck'
.'emhgeji';y,g-p,0-9,;my@x=map{-84+hex}m;\w.;g;my@
y=shift@x;push@y,\$_+\$y[-1]for@x;print(map{chr}@y);

I should have mentioned an additional requirement I imposed on myself: the code runs clean under use strict; and use warnings;

This is fun!

Regards,

Athanasius <°(((><contra mundum

Create A New User
Node Status?
node history
Node Type: obfuscated [id://969289]
Approved by tobyink
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2018-02-20 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When it is dark outside I am happiest to see ...

Results (267 votes). Check out past polls.

Notices?