Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Skytale cipher

by chargrill (Parson)
on Apr 04, 2006 at 04:28 UTC ( #541075=obfuscated: print w/ replies, xml ) Need Help??

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'',<DA +TA>; print join '' , map chr , @ $_ for 'A' .. ( sort keys ( % . ) ) [ -1 ] ; pr +int "\n" ; __DATA__ In cryptography, a scytale (also known as skytale) is a tool used to p +erform a transposition cipher, consisting of a cylinder w/ a strip of paper wou +nd around it on which is written a message across the windings, with the ciphert +ext consisting of the unwound paper. This is one way to implement such a +cipher.

$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%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[$%++]}

Comment on Skytale cipher
Select or Download Code
Replies are listed 'Best First'.
Re: Skytale cipher
by turo (Friar) on May 04, 2006 at 04:02 UTC

    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 array[0], the second to the array1, and so on up to reach the arrayW-1, the next char to the first array[0], 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"'

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2016-05-27 00:51 GMT
Find Nodes?
    Voting Booth?