***** infoCopter.com/perl *****

Crypt::CBC

Crypt::CBC - Encrypt Data with Cipher Block Chaining Mode

[ Cryptography in Perl ] - [ Crypt::Blowfish ] [ Crypt::CBC ] - [ My::Crypt ]

DES vs. Blowfish

Blowfish uses a Variable length key (32-448 bits) as compared to 56-Bit in DES. It depends what key length you choose with "blowfish". With the same key length Blowfish is faster than DES. The security depends on the choosen key length, as it would take more effort to decode a message encrypted with a larger key.

Some other encryption algorithms to consider are AES (more secure as 3-DES and faster), IDEA (not free for commercial use).

Blowfish

Free implementations available in Perl, C, Java, VisualBasic and probably more and on major platforms. BlowFish algorithm can encrypt all kind of file types.

Perl Sample

use Crypt::CBC;

$cipher = Crypt::CBC->new( {'key'             => 'my secret key',
                            'cipher'          => 'Blowfish',
                            'iv'              => '$KJh#(}q',
                            'regenerate_key'  => 0,   # default true
                            'padding'         => 'space',
                            'prepend_iv'      => 0
                           });

$ciphertext = $cipher->encrypt("This data is hush hush");

print "$ciphertext\n\n";

$plaintext  = $cipher->decrypt($ciphertext);

print "$plaintext\n\n";



DES

Perl Sample

use Crypt::CBC;

my $cipher = new Crypt::CBC('secret', 'DES');

my $ciphertext = $cipher->encrypt("This data is hush hush");

print "encrypted: '$ciphertext'\n";

my $decoded = $cipher->decrypt($ciphertext);

print "decrypted: '$decoded'\n";


© reto :)