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

Atbash cipher

by chargrill (Parson)
on Mar 29, 2006 at 06:58 UTC ( #539882=obfuscated: print w/ replies, xml ) Need Help??

A relatively simple obfuscation for a relatively simple substitution cipher. This either takes a file as a parameter to encrypt in atbash, or provided no input encrypt's it's __DATA__.

#!/usr/bin/perl open DATA,$ARGV[0]if$ARGV[0];$ ,=65;@ .=map$_,reverse chr$ ,..pack'c', +$ .;$.=$, +25;print join'',map{join'',map{$ *=ord>ord uc z?push(@%,/./)&&uc:push +(@%,0)&&$ _;$ ^=$ *=~/[chr$,-chr$.]/?$.[(ord$*)-$,]:$*;$%[$;++]?lc$^:$^}split q, +,,}<DATA> __DATA__ This is an implementation of an atbash (or 'zgyzhs') cipher, which enc +odes strings by replacing 'a' with 'z', 'b' with 'y', etc. This is my test + string. This string includes CAPital letters, spaces, punctuation, and newline +s. This tests EVERY capability of this implementation.

$,=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 Atbash cipher
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2015-09-04 22:24 GMT
Find Nodes?
    Voting Booth?

    My preferred temperature scale is:

    Results (148 votes), past polls