Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Not so cryptic

by iamcal (Friar)
on May 22, 2001 at 20:15 UTC ( [id://82263]=obfuscated: print w/replies, xml ) Need Help??

#!/usr/bin/perl -w use strict; $_="this super-code example shows clearly how encoded text is, siince a normal perl-codeblock should never-ever-ever contain it's method embedded within -its- decoder as is. right, you're wrong because my obstuf exempleifies it. honest programs should a) envoke and b-work prescripted though never through it."; my@a=map{(/\.|,/)?0:length}(m;([-\w']+|(?:,|\.));g); print chr hex sprintf('%x'x2,$$,shift@a)while($$=shift@a);
Go on, deconstruct it :)

Replies are listed 'Best First'.
Re: Not so cryptic
by srawls (Friar) on May 22, 2001 at 23:36 UTC
    Very interesting. Here's how it works.
    $_="this super-code example shows clearly how encoded text is, siince a normal perl-codeblock should never-ever-ever contain it's method embedded within -its- decoder as is. right, you're wrong because my obstuf exempleifies it. honest programs should a) envoke and b-work prescripted though never through it."; = Each word's length is how he encodes "just another perl hacker". Somet +imes he mis-spells the words to get the right length: for example sii +nce. =cut my@a=map{(/\.|,/)?0:length}(m;([-\w']+|(?:,|\.));g); = the regex matches each word, so each word is passed to map. Periods an +d commas return 0, which is the null character, thus not taking up an +y space. He does this so he can punctuate his string. As I said ear +lier, the length of each word is returned. =cut print chr hex sprintf('%x'x2,$$,shift@a)while($$=shift@a); = Here he goes through @a by twos, performing sprintf ('%x%x',$$, shift @a) each time through. The result is a hexadecimal number for each word, +formed by the word's length. Then he uses hex to turn that hex numbe +r into decimal, and chr to turn it into it's ascii equivalent. =cut

    If I have made any mistakes, please inform me; I'm new to obfuscated code myself, but I liked this very much--good job iamcal.

    Update: Good job tachyon. That's what I was trying to say, but I think you expressed it so much more clearly than me.

    The 15 year old, freshman programmer,
    Stephen Rawls

Re: Not so cryptic
by tachyon (Chancellor) on May 23, 2001 at 00:32 UTC
    Deconstruction a speciality. Rather than explain extensively I have gone for the plain perl recoding approach to make it blindingly obvious how this works. I like this JAPH. cheers tachyon #!/usr/bin/perl -w use strict; # this string identifies the key encoding features basically the # length, but also the . and , The ) is meaningless other than # not meaning something! The final full stop does nix. $_="xxxx xxxxxxxxxx xxxxxxx xxxxx xxxxxxx xxx xxxxxxx xxxx xx, xxxxxx x xxxxxx xxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxx xxxxxxx xxxx xxxxxx xxxxxxxx xxxxxx xxxxx xxxxxxx xx xx. xxxxx, xxxxxx xxxxx xxxxxxx xx xxxxxx xxxxxxxxxxxx xx. xxxxxx xxxxxxxx xxxxxx x) xxxxxx xxx xxxxxx xxxxxxxxxxx xxxxxx xxxxx xxxxxxx xx."; # this loop replaces the map for (m/x+|[\.,]/g) { push @a, eval'(/[\.,]/) ? 0 : length $_'; } # net result of map step is: # @a = qw(4 10 7 5 7 3 7 4 2 0 6 1 6 14 6 15 7 4 6 8 6 5 7 2 2 0 5 0 6 + 5 7 2 6 12 2 0 6 8 6 1 6 3 6 11 6 5 7 2 0); # this breaks down the second line into self evident steps while ($foo = shift @a) { $hex_code1 = sprintf "%x", $foo; $hex_code2 = sprintf "%x", shift @a; $hex = $hex_code1.$hex_code2; $dec = hex $hex; $ascii = chr $dec; print $ascii; } # Notes $$ is the $PID, I substitute $foo just because # %x is unsigned integer in hex so sprintf %x, $foo converts $foo # to hex. # The '%x'x2 is the same as "%x%x" # sprint "%x%x", $a ,$b; shoves both $a and $b into hex format
      exellent breakdown - completely correct.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://82263]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-06-15 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.