Cipher::Caesar - Simple modular-addition cipher
my &rot13 := Cipher::Caesar.encipherer; # Defaults to rot13 my $julius = Cipher::Caesar.new(:shift(3)); print rot13("Insert secret here"); print $julius.cipher("Attack at dawn");
Cipher::Caesar implements simple byte-level modular addition ciphers, including rot13, the Caesar cipher (add or subtract values from all letters), and an unnamed similar cipher where all bytes are changed, not just letters.
Cipher::Caesar conforms to the standard Cipher API; see "Using the Cipher API" in Cipher for general information.
With no options, Cipher::Caesar creates a rot13 encipherer/decipherer (rot13 draws no distinction between them.) The :shift(N) option can be used to select a different number of letters to shift (e.g. Julius Caesar used 3; Augustus Caesar used 1). If a shift is specified, you should also specify either :mode<enciphering> or :mode<deciphering>. The :all option will cause the module to shift across all byte values, not just the ones corresponding to letters.
:shift(N)
:mode<enciphering>
:mode<deciphering>
:all
Caesar ciphers provide extremely trivial security; a cryptanalyst need only graph the letter frequency to crack the cipher, and even if the message is contrived to hide the letter frequency, the keyspace is only 26. You would have to be insane to use this for anything more than obscuring text from accidental viewing. (rot13 in particular is often used for obscuring spoilers, answers, and punchlines.)
Cipher
David Kahn, The Codebreakers - The Story of Secret Writing, 1967. ISBN 0684831309.
To install Perl6::Pugs, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl6::Pugs
CPAN shell
perl -MCPAN -e shell install Perl6::Pugs
For more information on module installation, please visit the detailed CPAN module installation guide.