NAME

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

SYNOPSIS

# WITHIN MAIN
use Crypt::Cipher;
my $obj = Crypt::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
Crypt::Cipher->clean();                              #Memory cleanup

# AS INHERITED BASE CLASS
package Crypt::Cipher::NewCipher;
@ISA = qw(Crypt::Cipher);
 
sub new {
    my $class = shift;
    ...
    ...
    return Crypt::Cipher::new($class,$from,$to);
}

# Crypt::Cipher::NewCipher automatically creates all of the above
# methods.

# Aliasing example: make Crypt::Cipher::NewCipher::flush operate 
# just like Crypt::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 Crypt::Cipher class. When called as Crypt::Cipher->new(DOMAIN, MAPPING), it creates an object mapping each letter in DOMAIN to its respective letter in MAPPING, as per the tr/// operator.

$obj->bind(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->trans(LIST)

    In scalar context, this method transliterates the first scalar in the list and returns the transliterated string in scalar context. In list context, transliterates each element in the list and returns a new list consisting of the transliterated values.

CLASS->clean()

    Performs operations to recover memory, which may or may not make a substantial change in the speed of your code.

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 Crypt::Cipher::new('Crypt::Cipher::NewClass',$from,$to);

    Replace "Crypt::Cipher::NewClass" with your class's name, 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 Crypt::Cipher::encipher($obj,@params);
    }

    If you are trying to do something even fancier, please ensure that any other impelementation of Crypt::Cipher or any other cipher built on Crypt::Cipher would still function using your code.

HISTORY

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 96:

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

Around line 138:

=back without =over

Around line 144:

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

Around line 182:

=back without =over

Around line 204:

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