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

NAME

Text::Cipher - Very flexible base class for text ciphers.

SYNOPSIS

  # WITHIN MAIN
  use Text::Cipher;
  my $obj = Text::Cipher->new($domain,$mapping);       #Constructor
  my $storage = $obj->encipher("some string");         #String op
  $obj->encipher_scalar(\$some_scalar);                #Scalar ref op
  my @big_storage = $obj->encipher_list("2nd string",  #List operator
                                        "and another",
                                        "and more",   
                                        "yet more");
  $obj->encipher_array(\@some_array);                  #Array operator
  Text::Cipher->clean();                              #Memory cleanup
  
  # AS INHERITED BASE CLASS
  package Text::Cipher::NewCipher;
  @ISA = qw(Text::Cipher);
   
  sub new {
      my $class = shift;
      ...
      ...
      return $class->SUPER::new($from,$to);
  }

  # Text::Cipher::NewCipher is automatically supplied the cipher
  # methods.

  # Aliasing example: make Text::Cipher::NewCipher::flush operate 
  # just like Text::Cipher::clean.
  BEGIN { *flush = \&Crypt::Cipher::clean };  

ABSTRACT

Provides a standard interface and simple methods for ciphers of various kinds, saving on development time and redundant code.

DESCRIPTION

Use as an Independent Class

Crypt::Cipher->new(PARAMLIST)

    This method is the constructor for the Text::Cipher class. When called as Text::Cipher->new(DOMAIN, MAPPING, MODS), it creates an object mapping each letter in DOMAIN to its respective letter in MAPPING. MODS are modifieres to the cipher as per the tr/// operator.

$obj->encipher(STRING)

$obj->encipher_string(STRING)

    Performs the cipher on the string and returns the enciphered value.

$obj->encipher_scalar(SCALARREF)

    This method takes a reference to a scalar (note that it does not create the reference to the scalar) and performs the cipher upon the scalar it refers to. It returns true if anything in the scalar was changed through the application of the cipher.

$obj->encipher_list(LIST)

    Returns the list after applying $obj->encipher on every element.

$obj->encipher_array(ARRAYREF)

    Calls $obj->encipher on every element in the array pointed to by the ARRAYREF.

Text::Cipher->clean()

    Performs operations to recover memory, which may or may not make a substantial change.

Use as a Base Class

Default Use

    If you just want to use the methods provided to you by the class, all you have to do is end your constructor with the following code snippet:

        return $class->SUPER::new($from,$to);

    The $class variable should be the name of your class, and $from should contain the letters your cipher will change (aka: SEARCHLIST) while $to should contain the letters your cipher will move things over to (aka: REPLACEMENTLIST).

Overloading

    If you want to overload a method (the "new" method is popular to overload, as is the "clean" method), then just be sure to end your new method with a call to this class's method.

        # Example
        sub encipher {
            my $obj = shift;
            ...
            return $obj->SUPER::encipher(@params);
        }

    If you are trying to do something even fancier, please ensure that any other impelementation of Text::Cipher or any other cipher built on Text::Cipher and your code would still function. Generally, this can be acheived by defining a class verison of $obj-encipher> and $obj-encipher_scalar>, as most the other methods are built in reference to those two.

Provided Constant Subroutines

UPPERCASE

    By default, set to join("","A".."Z"), but not explicitly defined as such. This value should be set as a string which contains all the "capital" or "big" values of the alphabet in which you are working, starting at the "first" letter and going to the "last" letter.

LOWERCASE

    By default, set to join("","a".."z"), but not explicitly defined as such. This value should be a string which contains all the values of the lowercase alphabet in which you are working, starting at the "first" letter and going to the "last" letter.

4 NUMBERS

    By default, set to join("",0..9), but not explicitly defined as such. This value should be a string which contains all the values of the numerical alphabet in which you are working, starting at the "first" number and going to the "last" number.

HISTORY

1.01

Tested under Perl 5.6, thanks to John Alden.

1.00

Renamed to Text::Cipher in order to better represent its purpose (most text ciphers are not secure and applications to non-text values are unintuitive). Provided alphabet constants and registered with PAUSE.

0.02

Fixed minor inheritance bugs and documentation. Also fixed a major bug occuring when used in list context.

0.01

Original version; created by h2xs 1.22 with options

  -ABCX
        -n
        Crypt::Cipher

SEE ALSO

AUTHOR

Robert Fischer, <chia@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2003 by Robert Fischer

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

5 POD Errors

The following errors were encountered while parsing the POD:

Around line 117:

You forgot a '=back' before '=head3'

Around line 175:

=back without =over

Around line 181:

You forgot a '=back' before '=head3'

Around line 261:

=back without =over

Around line 298:

=back doesn't take any parameters, but you said =back 4