in reply to Some everyday code.
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 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];
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]; push(@r,$m); print chr( ord(substr($t,$y+3,1)) ^ $r[$y] ^ 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.#!/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);
|
---|