$_=q|P"\e[2J\n";SQw{my$s;select$s,$s,$s,H}SQc{P"\e[12;1f\n"}($_=pop)?open+DAT A,$_:$@;$k=N"",MQuc,grep/[a-z]/,M$.{$_}++or$_,$0=~/\w/g;@s=($k=~/./g,grep/[^J $k]/,(A..Z));@Z=@s;F$r(0..4){$t[$r][$_]=H@sQFQ0..4}$t.=N"",grep/[A-Z]/,MQuc,/ ./gQF ;$_= $t;s/ (\w)\ 1/$1X $1/g;(y ///c% 2)& &($_. ="X ");@e =/. ./g ;$E=N "Q",@ e;$ D=1 3;$C= 1;F $o(1. .11){ M{P$o %2? ($_ -1)%4 ?"\e[ $o; ${_ }f.": "\e [$o;$ {_} f". ($o== 1?" .": ":"): ($_-1 )%4 ?"" :"\e[ $o; ${_}f :"} 1.. 21}F$ z(2 ..1 0){ne xtQif $z% 2;M {(P(" \e[ $z;${ _}f ".( H@Z)) &&( &c& &w.03 ))if( ($z -1) %2)&& !(( $_+1) %4);}3..1 9}SQb {($I, $x,$y )=@_; $r= 0;M{$ c=0 ;M{/$ y/& &U@ $I,$c .$r ;/$x/ &&unH @$I ,$c.$ r;$ c++}@ $_; $r+ +}@t} SQf {P"\e [12;1 f\e [0J\n "}S Qa{my ($x ,$y ,$t,$ f,@ r)=H= ~/./g ;s/ J/I/F $x,$y;$w= 0;b\@ r,$ x,$ y;M{( $h, $i)=/ ./g;$ p=++$ h>4?0 :$h;$ t.=$t [$i][$p];if($iQeq$w){$j++}else{$w=$i;$j=0}}@r;$j?$t:0}SQe{my($x,$y,$t,@r)=H=~ /./g;s/J/I/F$x,$y;b\@r,$x,$y;$s=$o=$f=0;M{($c,$d)=/./g;if($o++){$f++if$s==$c} else{$s=$c}$d+=$d>3?-4:1;$t.=$t[$d][$c]}@r;$f?$t:0}SQn{my($x,$y,$t,@r,$Y)=H=~ /./g;s/J/I/F$x,$y;b\@r,$x,$y;$_=N":",@r;s/(\d)(\d):(\d)(\d)/$2$3:$4$1/;M{($e, $f)=/./ g;$t.=$t[$e] [$f]}L/:/;$t}SQ k{($l1,$lt,@ R)=H=~/./ g;b\@R, $l1,$lt;N":",@R}S Qj{N"-",k($_[0 ]),k$_[1]}SQ h{ my($t,$b ,$l,$r, $c)=@_;F$o($t..$ b ){M{P"\e[$o;$ {_}f$c"if(($ o%2 )or!(($ _-1)%4) )}$l..$r}c}SQi{ my( $t,$b,$l,$r) =@_;F$o($t.. $b) {F($l.. $r){P"\ e[$o;${_}f."if$ o%2 ;P"\e[$o;${_ }f".($o==1?" ." :":")unl ess($_- 1)%4}}c}SQd{ my($x,$y,$h, $C)=@_;$l=($ x+1)*2;$c =($y+1) *4-1;$h?h$l-1,$ l+1 ,$c-2,$c+2,$ C:i$l-1,$l+1 ,$ c-2,$c+2 }SQp{my ($p,$h,$c)=@_;M {d/ ./g,$h,$c}L/ :/,$p}SQg{my ($p ,$e)=@_ ;$j=j$p ,$e;($A,$B)=(L/ -/, $j);p$A,1,"* ";c;w.02;p$B ,1, "@";c;w .01;$D= =13&&$C==1&&&f; P"\ e[$D;${C}f$p Q->Q$e\n";$C +=$ D>19?$C <60?12:1-$C:0;$D+=$D<20?1:-7;p$A,0;p$B,0;c;w.01;}F(@e){if($T=a$_){g$_,$T;U@c, $T}elsif($T=e$_){g$_,$T;U@c,$T}else{$P=$_;$T=n$_;g$P,$T;U@c,$T}}|;s.\s..g;s:P :print:gx;s:U:push:g;s+N+join+g;s,M,map,g;s:S:sub:g;s'H'shift'g;s-L-split-g;; s;F;for;g;s,Q, ,g;s/([^f])or/$1||/g;eval;&f;print"encrypted:\n@c\n";chargrill __DATA__ The Playfair cipher is a manual symmetric encryption technique and was the first literal digraph substitution cipher. The scheme was invented in 1854 by Charles Wheatstone, but bears the name of Lord Playfair who promoted the use of the cipher. The technique encrypts pairs of letters (digraphs), instead of single letters as in the simple substitution cipher and rather more complex Vigenere cipher systems then in use. The Playfair is thus significantly harder to break since the frequency analysis used for simple substitution ciphers does not work with it.