Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi all,

this is my very first post here. I'd like to talk about my latest japh. My previous attempts had concentrated on either code or data obfuscation by means of tons of stuff like q* constructs with strange delimiters, eval(), and so on.

For this particular one instead I had a precise algorithm in mind. Eventually it turned out to be more of a golfing exercise than an obfuscation one. All in all there's no obfuscation at all and not much data obfuscation either, in the sense that it is clear to see *where* it is stored. Still IMHO it's not so easy to understand *what* the algorithm does and *why* it works. Here it is:

{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB=' .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_, 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Note that it's not a japh in the strictest sense, i.e. it doesn't simply print() "Just another Perl hacker,\n". Also, the effect it achieves is manifest under xterms and at *DOS prompt, whereas Linux console, even with $|==1 is too fast for it. A variant in which I slow it down by making it do a "few" unnecessary operations is
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB=' .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_, 256),-9999..249,7);s/[^\w,]/ /g;$\=/^J/?$/:"\r";print,redo}
Despite what some people think about this kind of exercises, it turned out to be very instructive.

For example the first versions of this japh were so verbose that I didn't hope it would have been possible to shrink it to fit in .sig's standards. A big improvement was obtained when I realized that I didn't need to work with strings of "\0" and "\01" as I had initially assumed, but that any two chars would do instead. This is obvious if you think about the possible outcome of an expression of the kind a*b*c where * is a binary operation "of the kind of XOR" and a,b, and c can take two values only. But it was not so obvious until I stopped to think about it...


In reply to My 1st post (japh) by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-29 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found