1Blowfish(3) User Contributed Perl Documentation Blowfish(3)
2
3
4
6 Crypt::Blowfish - Perl Blowfish encryption module
7
9 use Crypt::Blowfish;
10 my $cipher = new Crypt::Blowfish $key;
11 my $ciphertext = $cipher->encrypt($plaintext);
12 my $plaintext = $cipher->decrypt($ciphertext);
13
14 You probably want to use this in conjunction with
15 a block chaining module like Crypt::CBC.
16
18 Blowfish is capable of strong encryption and can use key sizes up to 56
19 bytes (a 448 bit key). You're encouraged to take advantage of the full
20 key size to ensure the strongest encryption possible from this module.
21
22 Crypt::Blowfish has the following methods:
23
24 blocksize()
25 keysize()
26 encrypt()
27 decrypt()
28
30 blocksize
31 Returns the size (in bytes) of the block cipher.
32
33 Crypt::Blowfish doesn't return a key size due to its ability to use
34 variable-length keys. More accurately, it shouldn't, but it does
35 anyway to play nicely with others.
36
37 new
38 my $cipher = new Crypt::Blowfish $key;
39
40 This creates a new Crypt::Blowfish BlockCipher object, using $key,
41 where $key is a key of "keysize()" bytes (minimum of eight bytes).
42
43 encrypt
44 my $cipher = new Crypt::Blowfish $key;
45 my $ciphertext = $cipher->encrypt($plaintext);
46
47 This function encrypts $plaintext and returns the $ciphertext where
48 $plaintext and $ciphertext must be of "blocksize()" bytes. (hint:
49 Blowfish is an 8 byte block cipher)
50
51 decrypt
52 my $cipher = new Crypt::Blowfish $key;
53 my $plaintext = $cipher->decrypt($ciphertext);
54
55 This function decrypts $ciphertext and returns the $plaintext where
56 $plaintext and $ciphertext must be of "blocksize()" bytes. (hint:
57 see previous hint)
58
60 my $key = pack("H16", "0123456789ABCDEF"); # min. 8 bytes
61 my $cipher = new Crypt::Blowfish $key;
62 my $ciphertext = $cipher->encrypt("plaintex"); # SEE NOTES
63 print unpack("H16", $ciphertext), "\n";
64
66 Please see the README document for platforms and performance
67 tests.
68
70 The module is capable of being used with Crypt::CBC. You're encouraged
71 to read the perldoc for Crypt::CBC if you intend to use this module for
72 Cipher Block Chaining modes. In fact, if you have any intentions of
73 encrypting more than eight bytes of data with this, or any other block
74 cipher, you're going to need some type of block chaining help.
75 Crypt::CBC tends to be very good at this. If you're not going to
76 encrypt more than eight bytes, your data must be exactly eight bytes
77 long. If need be, do your own padding. "\0" as a null byte is
78 perfectly valid to use for this.
79
81 Crypt::CBC, Crypt::DES, Crypt::IDEA
82
83 Bruce Schneier, Applied Cryptography, 1995, Second Edition, published
84 by John Wiley & Sons, Inc.
85
87 The implementation of the Blowfish algorithm was developed by, and is
88 copyright of, A.M. Kuchling.
89
90 Other parts of the perl extension and module are copyright of Systemics
91 Ltd ( http://www.systemics.com/ ).
92
93 Code revisions, updates, and standalone release are copyright 1999-2010
94 W3Works, LLC.
95
97 Original algorithm, Bruce Shneier. Original implementation, A.M.
98 Kuchling. Original Perl implementation, Systemics Ltd. Current
99 maintenance by W3Works, LLC.
100
101 Current revision and maintainer: Dave Paris <amused@pobox.com>
102
103
104
105perl v5.32.0 2020-07-28 Blowfish(3)