#!/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;