Crypt-Blowfish
view release on metacpan or search on metacpan
Blowfish.pm view on Meta::CPAN
Crypt::Blowfish - Perl Blowfish encryption module
=head1 SYNOPSIS
use Crypt::Blowfish;
my $cipher = new Crypt::Blowfish $key;
my $ciphertext = $cipher->encrypt($plaintext);
my $plaintext = $cipher->decrypt($ciphertext);
You probably want to use this in conjunction with
a block chaining module like Crypt::CBC.
=head1 DESCRIPTION
Blowfish is capable of strong encryption and can use key sizes up
to 56 bytes (a 448 bit key). You're encouraged to take advantage
of the full key size to ensure the strongest encryption possible
from this module.
Crypt::Blowfish has the following methods:
Blowfish.pm view on Meta::CPAN
my $ciphertext = $cipher->encrypt("plaintex"); # SEE NOTES
print unpack("H16", $ciphertext), "\n";
=head1 PLATFORMS
Please see the README document for platforms and performance
tests.
=head1 NOTES
The module is capable of being used with Crypt::CBC. You're
encouraged to read the perldoc for Crypt::CBC if you intend to
use this module for Cipher Block Chaining modes. In fact, if
you have any intentions of encrypting more than eight bytes of
data with this, or any other block cipher, you're going to need
B<some> type of block chaining help. Crypt::CBC tends to be
very good at this. If you're not going to encrypt more than
eight bytes, your data B<must> be B<exactly> eight bytes long.
If need be, do your own padding. "\0" as a null byte is perfectly
valid to use for this.
=head1 SEE ALSO
Crypt::CBC,
Crypt::DES,
Crypt::IDEA
Bruce Schneier, I<Applied Cryptography>, 1995, Second Edition,
published by John Wiley & Sons, Inc.
=head1 COPYRIGHT
The implementation of the Blowfish algorithm was developed by,
and is copyright of, A.M. Kuchling.
2.12 04 Mar 2010
- updated Changes to mesh with revision.
2.11 Feb 2010
- patched _blowfish.c to stop spurious warnings.
- updated POD
2.10 Fri Dec 02 07:36:18 EST 2005
- updated the README file to remove the reference
to CBC_R - no longer available.
- updated the README file to include performance
results for G4/1.2GHz PPC Mac OS X 10.4.X
2.09 Tue Nov 13 01:28:26 EST 2001
- changed keysize back to 0
apparently setting keysize to 8 triggered a bad hack
in Crypt::CBC which resulted in OpenSRS breaking.
the "bad hack" in question is:
$ks = $cipher =~ /blowfish/i ? 56 : 8 unless $ks > 0;
... anyway.. fixed.
2.08 Tue Oct 30 23:29:25 EST 2001
- added two new functions: min_keysize and max_keysize
these allow modules like Crypt::CBC_IL and Crypt::CBC_R
to use variable key lengths with CBC modes.
- cleaned up test.pl
- updated README
2.07 Thu Nov 30 02:59:29 EST 2000
- minor change in XS
- additions to reported platforms
2.06 Tue Jul 04 15:35:34 EST 2000
- Win32 tested using VC++5.0, all tests passed on NT4/SP5
This is Crypt::Blowfish version 2.11, an XS-based implementation of the
Blowfish cryptography algorithm designed by Bruce Schneier. It's designed
to take full advantage of Crypt::CBC when desired. Blowfish keys may be
up to 448 bits (56 bytes) long. This module builds on nearly every platform
that Perl itself does (see Notes for exceptions).
Prerequisites
-------------
For the full test suite to run, Crypt::CBC, version 1.22 or higher
is required (recommended is 1.25 or higher), however this module
is not mandatory for standalone Blowfish use.
Installing Crypt::Blowfish
--------------------------
nothing unusual:
1. perl Makefile.PL
2. make
my $td = Benchmark::timediff($t1,$t0);
my $ts = Benchmark::timestr($td);
print "10,000 cycles: $ts\n";
}; # end standard mode (decrypt) speed test cached cipher
print "\nTesting Cipher Block Chaining..\n";
eval 'use Crypt::CBC';
if(!$@) {
if($Crypt::CBC::VERSION < 1.22) {
$@ = "CBC mode requires Crypt::CBC version 1.22 or higher.";
} else {
my $cipher = new Crypt::CBC(pack("H*","0123456789ABCDEFF0E1D2C3B4A59687"),"Blowfish");
my $ciphertext = $cipher->encrypt(pack("H*","37363534333231204E6F77206973207468652074696D6520666F722000"));
my $plaintext = $cipher->decrypt($ciphertext);
if($plaintext eq "7654321 Now is the time for \0") {
print "ok 11 - CBC Mode\n";
} else {
print unpack("H*",$plaintext) . " :decrypted\n";
print unpack("H*","7654321 Now is the time for \0") . " :orig\n";
print "not ok 11 - CBC Mode failed\n";
}
}
} # end no errors
if($@) {
print "Error (probably harmless):\n$@\n";
}
( run in 0.886 second using v1.01-cache-2.11-cpan-df04353d9ac )