How to break down this obstufication...

First break it up into readable code:

#!/usr/bin/perl $t=("wrongwaywrongwaywrongwaywrongwaywrongwaywrongwaywrongwaywrongway" +); @j=(83,13,11,16,-61,3,60,-4,-63,60,1,-23,25,-43,-23,55,-11,-53,45,-59, +77,1,10,-5); my $c=("wrongway yes i said wrongway who else ?"); $m=0; for ($y=0;$y<$#j+1;$y++){ $m=$m+$j[$y]; push(@r,$m); print chr ord chr(ord(substr($t,$y+3,1))^ord(chr($r[$y]))^ord chr +ord chr ord(chr(ord(substr($c,$y,1))))); } print " - ". substr($c,20,8); sleep $j[5];
Next we'll cancel out the redundant pairs of chr & ord and remove the (annoying) sleep

#!/usr/bin/perl $t=("wrongwaywrongwaywrongwaywrongwaywrongwaywrongwaywrongwaywrongway" +); @j=(83,13,11,16,-61,3,60,-4,-63,60,1,-23,25,-43,-23,55,-11,-53,45,-59, +77,1,10,-5); my $c=("wrongway yes i said wrongway who else ?"); $m=0; for ($y=0;$y<$#j+1;$y++){ $m=$m+$j[$y]; push(@r,$m); print chr( ord(substr($t,$y+3,1)) ^ $r[$y] ^ ord(substr($c,$y,1)) +); } print " - ". substr($c,20,8);
And now we notice that @r is redundant:

#!/usr/bin/perl $t=("wrongwaywrongwaywrongwaywrongwaywrongwaywrongwaywrongwaywrongway" +); @j=(83,13,11,16,-61,3,60,-4,-63,60,1,-23,25,-43,-23,55,-11,-53,45,-59, +77,1,10,-5); my $c=("wrongway yes i said wrongway who else ?"); $m=0; for ($y=0;$y<$#j+1;$y++){ $m=$m+$j[$y]; print chr( ord(substr($t,$y+3,1)) ^ $m ^ ord(substr($c,$y,1)) ); } print " - ". substr($c,20,8);
And the code is now pretty obvious. Loop through @j using a for loop on $y. Increment $m by the current value from @j, then XOR a character from $t, one from $c and the current value of $m. Then finally print out a sub string of $c.

In reply to Re: Some everyday code. by iamcal
in thread Some everyday code. by WrongWay

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.