Crypt::Cipher::Twofish(3) User Contributed Perl Documentation Crypt::Cipher::Twofish(3)

Crypt::Cipher::Twofish - Symmetric cipher Twofish, key size: 128/192/256 bits

### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...';  # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Twofish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Twofish;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...';  # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Twofish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");

This module implements the Twofish cipher. Provided interface is compliant with Crypt::CBC module.

BEWARE: This module implements just elementary "one-block-(en|de)cryption" operation - if you want to encrypt/decrypt generic data you have to use some of the cipher block modes - check for example Crypt::Mode::CBC, Crypt::Mode::CTR or Crypt::CBC (which will be slower).

$c = Crypt::Cipher::Twofish->new($key);
#or
$c = Crypt::Cipher::Twofish->new($key, $rounds);

$ciphertext = $c->encrypt($plaintext);

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

$c->keysize;
#or
Crypt::Cipher::Twofish->keysize;
#or
Crypt::Cipher::Twofish::keysize;

$c->blocksize;
#or
Crypt::Cipher::Twofish->blocksize;
#or
Crypt::Cipher::Twofish::blocksize;

$c->max_keysize;
#or
Crypt::Cipher::Twofish->max_keysize;
#or
Crypt::Cipher::Twofish::max_keysize;

$c->min_keysize;
#or
Crypt::Cipher::Twofish->min_keysize;
#or
Crypt::Cipher::Twofish::min_keysize;

$c->default_rounds;
#or
Crypt::Cipher::Twofish->default_rounds;
#or
Crypt::Cipher::Twofish::default_rounds;

2024-10-20 perl v5.40.0