Skytale cipher
chargrill
created: 2006-04-04 00:28:55

A slightly less simple obfuscation for a slightly less simple substitution cipher. The next stop in my tour of old forgotten encryption ciphers is this skytale implementation. This either takes a file as a parameter to encrypt in skytale, or provided no input encrypt's it's __DATA__.

#!/usr/bin/perl

open DATA,$ARGV[0]if$ARGV[0];$;=$0=~y~a-z~~;map{m'(\d+)(?{$*=chr$,+65;push@{$*},
$^N;$.{$*}++;$,=$,<$;?++$,:0})'}grep!/^10$/,map ord,split//,join'',; print
join '' , map chr , @ $_ for 'A' .. ( sort keys ( % . ) ) [ -1 ] ;  print "\n" ;

__DATA__
In cryptography, a scytale (also known as skytale) is a tool used to perform a
transposition cipher, consisting of a cylinder w/ a strip of paper wound around
it on which is written a message across the windings, with the ciphertext
consisting of the unwound paper.  This is one way to implement such a cipher.


--chargrill
$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse split//=>$*
){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$#C]=$/;($#C
>$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^$$C[$%++]}
Re: Skytale cipher
created: 2006-05-04 00:02:08

Good Implementation :-) ...

Your scitale has a width (W) denoted by the number of lower cups characters the filename has, plus one.

Then, you use W arrays for storing each character from the plaintext; first character on the plaintext to the array0, the second to the array1, and so on up to reach the arrayW-1, the next char to the first array0, etc.

Cool!, i've made an implementation of this cipher (i like too much these topic) a long time ago (i do not remember where did i put it), but for sure my impl. was unobfuscated an i think i made W reads of the plaintext for encoding and decoding. Not too optimal, but easy to understand :-) (ummm... i don't rememeber if i've made it in perl ... or it was in awk? ... anyway)

perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

perlmonks.org content © perlmonks.org and chargrill, turo

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03