The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Crypt::Polybius - implementation of the Polybius square

SYNOPSIS

   use Crypt::Polybius;
   
   #      1    2    3    4    5
   # 1    A    B    C    D    E
   # 2    F    G    H    I/J  K
   # 3    L    M    N    O    P
   # 4    Q    R    S    T    U
   # 5    V    W    X    Y    Z
   #
   # ATTACK  ->  11 44 44 11 13 25
   # AT      ->  11 44
   # DAWN    ->  14 11 52 33
   
   my $square = Crypt::Polybius->new;
   
   print $square->encipher('Attack at dawn.'), "\n";

DESCRIPTION

This module provides an object-oriented implementation of the Polybius square, or Polybius checkerboard. This cipher is not cryptographically strong, nor completely round-trip-safe.

Roles

This class performs the following roles:

Constructors

new(%attributes)

Moose-like constructor.

new_with_traits(%attributes, traits => \@traits)

Alternative constructor provided by MooX::Traits.

Attributes

The following attributes exist. All of them have defaults, and should not be provided to the constructor.

square

An array of arrays of letters. Provided by Crypt::Role::CheckerboardCipher.

square_size

The length of one side of the square, as an integer. Provided by Crypt::Role::CheckerboardCipher.

encipher_hash

Hashref used by the encipher method. Provided by Crypt::Role::CheckerboardCipher.

decipher_hash

Hashref used by the decipher method. Provided by Crypt::Role::CheckerboardCipher.

Object Methods

encipher($str)

Enciphers a string and returns the ciphertext. Provided by Crypt::Role::CheckerboardCipher.

decipher($str)

Deciphers a string and returns the plaintext. Provided by Crypt::Role::CheckerboardCipher.

preprocess($str)

Perform pre-encipher processing on a string. encipher calls this, so you are unlikely to need to call it yourself.

The implementation provided by Crypt::Role::LatinAlphabet uppercases any lower-case letters, and passes the string through Text::Unidecode. It also replaces any letter J with I because the former is not found in the alphabet provided by Crypt::Role::LatinAlphabet.

alphabet

Returns an arrayref of the known alphabet. Provided by Crypt::Role::LatinAlphabet.

Class Method

with_traits(@traits)

Generates a new class based on this class, but adding traits.

Crypt::Role::ScrambledAlphabet is an example of an interesting trait that works with this class.

BUGS

Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Crypt-Polybius.

SEE ALSO

http://en.wikipedia.org/wiki/Polybius_square.

Crypt::Polybius::Greek.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2014 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.