Hi monks, this is my first post.
# Global mode (pretty slow on large files) $_=q qrea ncJertsa ,thelhPkour q,my $i=length; while($i){s/(.{$i})(.)/$2$1/g;--$i}print+$_.$/
# Non-global $_=q qnPteorJlt hhascekaerru, q,my $i=length; while($i){s/(.{$i})(.)/$2$1/;--$i}print+$_.$/;
# Opposite code: $_=q qJust another Perl hacker,q;until($i eq length){s/(.)(.{$i})/$2$1/g;++$i}print+$_.$/
It's very simple and easy to understand. Note: for files should be added '/s'

Replies are listed 'Best First'.
Re: Length obfuscation
by emilbarton (Scribe) on Aug 29, 2011 at 17:01 UTC

    Hi, I found your obfuscation nice and I was asking myself why it should be so simple and easy to understand. So I treated it permutationally and I propose the following de-obfuscation. It does not look much clearer unfortunately.

    There's a little problem in this code too: the seed for translation (right shift $tran=6012345) is not in itself obtained permutationally.

    P.S. the script should print:

    another--<-> ranothe--r<->anothe hranote--h<->ranot ohrante--o<->hran aohrnte--a<->ohr haornte--h<->ao ahornte--a<->h ahornte
    #!/usr/bin/perl $_=q qanotherq, my $l=length; while($l){s/(.{$l})(.)/$2$1/;--$l; print+$_."--".$2."<->".$1."\n"}; ## De-obfuscation: print &deobf("another")."\n"; sub deobf { my $n = 0; my (@tran,$res); my %h = map { $n++ => $_ } (split //,shift); while ($n > 0) { $n--; $res = $n.$res ; } $tran = $res; $tran =~ s/(.+)(.{1})/$2$1/; ## The shift seed. ## print "tran: $tran\n"; for ($n = 0; $n < length($res)-1; $n++) { $res = &comp(&perm($tran,$res),$n) } return join('',map{ $h{$_} } (split //,$res)); } ## END deobf() sub perm { my ($target,$agent) = @_; ## Max. base (string length) = 10. my @targ = split //,$target;## Digital permutations only.. my @perm = split //,$agent; ## e.g. 021, 3102, etc.. my $res; ## but not 031, 123, ... nor 0123456789A,.. for (my $i = 0; $i < (@perm); $i++){ $res .= $perm[$targ[$i]] } return $res; } ## END perm() sub comp { my ($res, $pos) = @_; if ($pos > 0){ my @perm = split //,$res; my $l = scalar(@perm); my $p1a = $perm[0]; my $p1b = $perm[$l-$pos]; $perm[0] = $p1b; $perm[$l-$pos] = $p1a; for (my $n = 0; $n < $pos; $n++){ my $p2a = $perm[$l-1]; my $p2b = $perm[$l-$n-1]; $perm[$l-1] = $p2b; $perm[$l-$n-1] = $p2a; } $res = join '', @perm; } return $res; } ## END comp() 1;
Re: Length obfuscation
by Marshall (Canon) on Oct 29, 2011 at 15:27 UTC
    No your code is not easy to understand.
    There is no question.
    What are you attempting to do?
    What is your purpose of this post?
      It's an obfuscation. ;)