Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Length obfuscation

by emilbarton (Scribe)
on Aug 29, 2011 at 17:01 UTC ( #923065=note: print w/ replies, xml ) Need Help??


in reply to Length obfuscation

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;


Comment on Re: Length obfuscation
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://923065]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2015-07-08 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls