Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Caesar Cipher

by moritz (Cardinal)
on Aug 04, 2013 at 19:43 UTC ( #1047821=note: print w/ replies, xml ) Need Help??


in reply to Caesar Cipher

a Caesar Cipher just substitutes each character for a fixed replacement. The easiest way to do that in Perl is with the tr operator:

use 5.010; use warnings; my $original = lc "Ceterum censeo Carthaginem esse delendam"; my $cyphered = $original; $cyphered =~ tr/a-z/k-za-j/; say $cyphered; my $decyphered = $cyphered; $decyphered =~ tr/k-za-j/a-z/; say $decyphered;


Comment on Re: Caesar Cipher
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-12-28 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls