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.

¤


In reply to It's a Shark. by frankus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.