# man > Crypt::Cipher::Blowfish

---
type: CommandReference
command: Crypt::Cipher::Blowfish
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `Crypt::Mode::CBC->new('Blowfish')->encrypt($data, $key, $iv)` — symmetric encryption with CBC mode (fast)
- `Crypt::CBC->new( -cipher=>'Cipher::Blowfish', -key=>$key, -iv=>$iv )->encrypt($data)` — encryption with CBC mode (slower)
- `$c = Crypt::Cipher::Blowfish->new($key)` — create cipher object for a given key
- `$c->encrypt($plaintext)` — encrypt a single block (16 bytes)
- `$c->decrypt($ciphertext)` — decrypt a single block
- `$c->keysize` — return key size (in bytes)
- `$c->blocksize` — return block size (always 8 bytes)
- `$c->default_rounds` — return default number of rounds

## Name
Symmetric cipher Blowfish, key size: 64-448 bits

## Synopsis
perl
use Crypt::Mode::CBC;

my $key = '...';   # length must be a valid key size for this cipher
my $iv  = '...';   # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Blowfish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);

# Alternative (slower)
use Crypt::CBC;
use Crypt::Cipher::Blowfish;

my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Blowfish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
**BEWARE:** This module only implements elementary “one-block (en|de)cryption”. To encrypt/decrypt arbitrary data, you must use a block cipher mode such as [Crypt::Mode::CBC](http://localhost/phpMan.php/perldoc/Crypt%3A%3AMode%3A%3ACBC/markdown), [Crypt::Mode::CTR](http://localhost/phpMan.php/perldoc/Crypt%3A%3AMode%3A%3ACTR/markdown), or [Crypt::CBC](http://localhost/phpMan.php/perldoc/Crypt%3A%3ACBC/markdown).

## Methods
- `new($key)` — create a cipher object with the given key
- `new($key, $rounds)` — create a cipher object with a custom number of rounds
- `encrypt($plaintext)` — encrypt a single 8‑byte block, return ciphertext
- `decrypt($ciphertext)` — decrypt a single 8‑byte block, return plaintext
- `keysize()` — return the key size in bytes
- `blocksize()` — return the block size (always 8)
- `max_keysize()` — return the maximum allowed key size
- `min_keysize()` — return the minimum allowed key size
- `default_rounds()` — return the default number of rounds

These can be called as instance or class methods, e.g. `$c->keysize` or `Crypt::Cipher::Blowfish->keysize`.

## Examples
perl
use Crypt::Mode::CBC;

my $key = '...';
my $iv  = '...';  # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Blowfish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
perl
use Crypt::CBC;
use Crypt::Cipher::Blowfish;

my $key = '...';
my $iv  = '...';  # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Blowfish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
## See Also
- [CryptX](http://localhost/phpMan.php/perldoc/CryptX/markdown)
- [Crypt::Cipher](http://localhost/phpMan.php/perldoc/Crypt%3A%3ACipher/markdown)
- [Crypt::Mode::CBC](http://localhost/phpMan.php/perldoc/Crypt%3A%3AMode%3A%3ACBC/markdown)
- [Crypt::Mode::CTR](http://localhost/phpMan.php/perldoc/Crypt%3A%3AMode%3A%3ACTR/markdown)
- [Crypt::CBC](http://localhost/phpMan.php/perldoc/Crypt%3A%3ACBC/markdown)
- [Blowfish cipher](https://en.wikipedia.org/wiki/Blowfish_(cipher))