http://qs321.pair.com?node_id=126571

Shark was the US name for the "Triton" enigma machine used on U-Boats.
The bulk of this code has appeared in Enigma Machine. It's no Dolphin ;-)

It encrypts whatever you type or pipe through it, run the encrypted output through it, and it'll decrypt it.
Warning Enigma was cracked over 50 years ago.

#!/usr/bin/perl use strict; my$s=q:$ /=';';%_=map{s/\s //g;chomp;/-/;$`,$'}<DAT A>; $_{$_}=[$_{$_}=~/\w+ /g]for('p','o');my$R=sub{my($n,$r)=@_;$r= ~s/[a-z]/$n =uc$&/e ;sub{return(chr(65+index$r,$_[0]) )if!$#_; $r=~/.{$_[1]}/;(substr ($r=$'.$&,ord($_[0]) - 65, 1),$'=~/^$n/*1)}};@_ =map{&$R(1,$_{$_})}(@{ $_{ o} });%_=map{ /./; $&, $',$',$&}@{$_{p}};$ /= "\n";while(<>) { s/[a-z]/$_=uc$& ;m y($ a,$i)=1;$_= $ _ {$_}||$_;for$i(1. .$#_){( $_,$a) = &{$_[$i]}($_,$a)}for ($i=$#_;$i-1;){$_=&{$ _[--$i]}( $_)}$_=$_{$_ }||$_/oxeig;print}:; ;$s =~ s/\s//g;eval $s __END__;1-EKMF LGDqVZ XNTOWYHUSPA IBRCJ;3 -AJDKS IR UXBL HWTMcQGZNPYF VOE;2 -BDFHJLC P RTXvZNYEIWGA K MUSQO;4-ESOVPZjAYQUI RHXLNFTGKDC MWB ;r-YRUHQ SLDPXN GOKMIE BFZCWVJAT;o -1,3,2,4, r;p-S H,AR ,KY ;

--

Brother Frankus.

¤