Rodrigo de Oliveira Gonzalez > Crypt-Blowfish-Mod-0.04 > Crypt::Blowfish::Mod

Download:
Crypt-Blowfish-Mod-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  

NAME ^

Crypt::Blowfish::Mod - Another Blowfish Algorithm

VERSION ^

version 0.04

SYNOPSIS ^

    use Crypt::Blowfish::Mod;

    my $cipher = new Crypt::Blowfish::Mod $key; 
    my $ciphertext = $cipher->encrypt($plaintext);
    $plaintext = $cipher->decrypt($ciphertext);

DESCRIPTION ^

Crypt::Blowfish::Mod implements the Blowfish algorithm using functions adapted from examples from Bruce Schneier and other authors.

Crypt::Blowfish::Mod has an interface similar to Crypt::Blowfish, but produces different results. This module is endianness sensitive, making sure that it gives the same encription/decription results in different architectures.

Also, this module accepts variable length keys up to 256 bytes. By default, it assumes the key is a Base64 string. And all text encrypted or decrypted is also in Base64.

METHODS ^

new

Usage:

    ## the key should be base64
    my $b = Crypt::Blowfish::Mod->new('YaKjsKjY0./');

    ## or use a raw key:
    my $b = Crypt::Blowfish::Mod->new( key_raw=>'this_is_a_raw_key9k&$!djf29389238928938' );

    my $enc = $b->encrypt( 'secret text' ); 
    my $dec = $b->decrypt( $enc );

If you prefer, work with raw encrypted strings:

    my $enc = $b->encrypt_raw( 'secret text' ); 
    my $dec = $b->decrypt_raw( $enc );

Or just call it even more raw (Big Endian):

    my $enc = Crypt::Blowfish::Mod::b_encrypt( $key, $str, 1 );
    my $dec = Crypt::Blowfish::Mod::b_decrypt( $key, $enc, 1 );

encrypt

Returns a encrypted string encoded in Base64.

decrypt

Decodes a base64 encoded blowfish encrypted string.

encrypt_raw

Returns a raw encrypted string.

decrypt_raw

Decodes a raw encoded blowfish encrypted string.

b_encrypt( Str $text, Str $key, Bool is_big_endian )

Raw C decrypt function.

b_decrypt( Str $text, Str $key, Bool is_big_endian )

Raw C decrypt function.

NOTES ^

The Blowfish algorithm is highly dependent on the endianness of your architecture. This module attempts to detect the correct endianness for your architecture, otherwise it will most likely default to little-endian.

You may override this behavior by setting the endianness on instantiation:

        # force little-endian
    my $b = Crypt::Blowfish::Mod->new( key=>'YaKjsKjY0./', endianness=>'little' );

Intel-based architectures are typically Little-Endian.

SEE ALSO ^

Crypt::Blowfish

Crypt::OpenSSL::Blowfish

This algorithm has been implemented in other languages:

http://www.schneier.com/blowfish-download.html

AUTHOR ^

Rodrigo de Oliveira, <rodrigo@cpan.org>

syntax highlighting: