Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

It's a Shark.

by frankus (Priest)
on Nov 20, 2001 at 22:19 UTC ( #126571=obfuscated: print w/ replies, xml ) Need Help??

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.

¤

Comment on It's a Shark.
Download Code
Re: It's a Shark.
by jarich (Curate) on Jul 16, 2004 at 08:08 UTC
    Unless there's a well known and obvious (but not documented here) restriction on the number of characters the machine will take, I think I've found a bug.

    Upon giving this the following input:

    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    (350 characters) I got the following output:
    DITIPICFWBFFFMGUGUOKOUGWOFYKMCWCHQYMTCPDRWZGICMSVIJVNRBNGUCXORIBSLJCFK CIZBHQYZGKJGDSZJYURTOPQOMHQSEZVTUPNOXJXHQELBLWUHKDNECWGYXBMFXFLGEWLSUC MOVDXZMYFCLHQJFURTOPGZDHQIKWDJFVXVLNGNLCKZBBDBTYPJGCSSXSOEURTOPVEXZNIX ELXZJLVELUNJDVHQMNWCFBCMFHQWZXGSMGDLJWYLBYWJFVBMWNSCCMHQSKDXKZGGRFKHLN QIUDHLGBTJQOOVORHTVGMXBYDECXKTRODEAZEBJCWCRWNBDXYEPPRITTGTYHZCFBAHGCHN
    So far so good...., however, attempting to decrypt that gives:
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT XOMPVBUNDGZYVJRYMYPHXDNTQWMYGQLVZZAEXSHOGNNGHDWOVHICLHIVKUIRRODSASILOO
    Hmm.

    After several other tests it appears that the machine can only return 279 clean alphabetical characters. Obviously since spaces and non-alphabetcial characters are ignored these can make it appear as if more clean characters are coming out, but that's not the case.

    What's happening here?

    jarich

      It's taken almost 3 years for someone to spot that :) .. when you work out how the rotors failing to work, I'll dig out a copy of the revised code I wrote two and a half years ago.. I might even get around to making it shark shaped ;)

      --

      Brother Frankus.

      ¤

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://126571]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-11-24 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (141 votes), past polls