I thought it would be fun to write an obfuscated "Playfair decryption", and since chargrill told me it was fine with him, and because today is my one-year anniversary at Perlmonks, I wanted to submit it by the end of the day. (Just barely made it!)
It runs under Windows. (I had intended it to work with Linux as well, but the "table" doesn't update quite right yet). The 3 parameters it takes (which can be "hardwired" at the top of the script) are:
$d = shift; $t = shift || "ocumentsadigjrkplhxbfqvwy"; $e = shift || "slobxtfqnrgmpfbukgadarsotxdvaweoaggoodmgfbngnidculipvcm +dtnmrasbuopjagqgnmktxnkjknxvjehasgncspntopfbugabutubueomrnjsfoddcnkdp +qexsgxudvxmdsancdohedlmdjaslodraocqpminbxtfqnrxmpuxicecndkslomdunoslo +upfbugabudculipvcmbodmgfbsaxngknuqpcdlamkangjxrlxnjtadcdnnonjtibcbcal +dcjadapisludrolhudehasgncspntopfbuxrtnxrslmkeckmucoxbchwgjodmkoupfbuj +avddcuaslodpisjcdbulhdwwngkjnslsjhagjipopmttsbqxskamkncxkmdjdpiuosloy +kmvcodeqdttxvdjnsjdkonjarolhudehasgncspntopfbujaneudinaqmirygnpjal"; ($a,$b)=eval{ require Win32::Console::ANSI}?(30, "4;7"):(100,"");$p={map{$_,[int$k/5,$k%5,$k ++]} split//,uc$t};$P={map{@_=@{$p->{$_}};$_[0].$_ [1 ] =>$ _ } keys %$p }; sub w($){ (4+ pop )%5} p ( "\e[$b;${a}m\e[2J") ;sub p{printf@_}sub P{select $A,$A,$A,$d if$d}sub c{my($c,$t,$f,$x,$y)=@_ ;if ($f){$x =3*$x+2 ;$y =3*$y+2;map{$q=$_;map{(2==$q &&2==$_)or c($c,' ',0,$x+$_,$y+$q)}(-1..1)}(-1.. 1)}$d && p"\e[%d;%dH\e[$b;%dm$t",$x,$y,$c+$a}map c(6,$_,1,@{$$p{$_}} ),keys% $p;p"\e[17H\e[%dm",$ a+5;p"$e\e[17H\e[s" ;P; sub l{( $u,$ v) =split// ,pop;($u,$U) =@{$ $p{$u }};($ v,$ V)=@ {$$p{$v}} ;$ h =sub {($ J,$ C,$N )=@ _;c($J,$P->{$C.$N},1, $C,$N)};($w,$W,$z,$Z)=($u==$v)?($u,w$U,$v,w$V):( $U==$V)?(w$u,$U,w$v,$V):($u,$V,$v,$U);$h->(1,$u, $U);$h->(2,$v,$V);P;$h->(6,$u,$U);$h->(6,$v,$V); $h->(1,$w,$W);$h->(2,$z,$Z);P;$h->(6,$w,$W);$h-> (6,$z,$Z);p"\e[u\e[%dm%s\e[s",$a+3,$P->{$w.$W}.$ P->{$z.$Z}}{l(uc substr($e,0,2,"")or last),redo}
In reply to Playfair Decryption by liverpole
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |