Mdc::EZcrypt


Mdc::EZcrypt


        Mdc::EZcrypt  version 2.009 -- 12Mar2004
        A string encryption module


Synopsis

        use Mdc::EZcrypt;
        $EZ = new Mdc::EZcrypt( key => 'mypassword' );
        $ciphertext = $EZ->encipher($plain_text);
        $plain_text = $EZ->decipher($ciphertext);


Description

An eazy to use symmetric encryption module that uses a very simple yet powerfull algorithm. The encrypted string returned by the encipher method will be encoded using MIME::Base64 by default. The output will be binary if the ``base64'' parameter is cleared or set to zero.


Algorithm

The EZcrypt algorithm compresses the plain text then generates two secure hash strings. The first hash string is created using the SHA1 fingerprint of the supplied key, salt string and a checksum of the compressed data. This hash string is expanded to equal the length of the compressed data.

The second hash string is created using the SHA1 fingerprint of the supplied key and salt string. This hash string is expanded to equal the length of the compressed data plus one.

The compressed data is XOR'ed with the first hash string. A checksum character is appended to the resulting ciphertext. Finally, the ciphertext and checksum character are XOR'ed with the second hash string.

Using a checksum character in this fassion, will gaurantee that the resulting encrypted data will be unique even if only one character in the plain text changes.

The secure hash function (SHA-1) is easily replaced with any another secure hash function


Methods

new

Create a new string encryption object.

        $c = new Mdc::EZcrypt(   key => 'mypassword',
                                  salt => '123XYZ',
                                Base64 => 1,
                                   eol => "\n"   );
key
Set the encryption password. This string may be any length.
        key => 'mypassword'

salt
Set the key salt. This string may be any length.
        salt => '123XYZ'

Base64
Enable or disable Base64 encoding. By default, the encrypted string will be encoded using the MIME::Base64 module. The returned encoded string is broken into lines of no more than 76 characters each. If the parameter ``eol'' is cleared, the encoded string will not be broken into separate lines. The parameter ``eol'' has no affect if ``Base64'' is disabled.
        Base64 => 1             # set output data encoding to MIME Base64 (default)
        Base64 => 0             # disable Base64 encoding

eol
Set the ``end of line'' character for Base64 encoding.
        eol => "\n"             # set end of line character to new line (default)
        eol => ""               # set end of line character to empty string

encipher

Encipher a plain text string.

        $c_text = $c->encipher($plain_text);

decipher

Decipher a ciphertext string.

        $plain_text = $c->decipher($c_text);


Author and Copyright

        This module was developed by Mark K Mueller who is always open to comments and suggestions.
        Email: mailto:mkmueller@cpan.org or visit http://www.markmueller.com/
        EZcrypt Copyright (c) 2003, Mark K Mueller
        Mueller Design and Consulting
        PO Box 576705, Modesto, CA 95357
        All Rights Reserved.
        This module is free software. It may be used, and redistributed under
        the same terms as Perl itself.


See Also

        Compress::Zlib, MIME::Base64, Digest::SHA1

MkM 11:53 PM 2003-09-03