Crypt::...er::IDEA(3)

🌸 NAME 🌸

Crypt::Cipher::IDEA β€” symmetric cipher IDEA, key size: 128 bits. this is the Crypt::Cipher::IDEA(3) page from the User Contributed Perl Documentation, and it's literally here to make IDEA make sense, bestie πŸ’…βœ¨

✨ SYNOPSIS ✨

okay so first, the iconic two-example moment 🫢

### example 1
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('IDEA');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);

### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::IDEA;

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

πŸ’– DESCRIPTION πŸ’–

this module implements the IDEA cipher, and its interface is compatible with Crypt::CBC. no cap.

note, bestie: this module only implements single-block encryption and decryption. for general data, use a block mode such as Crypt::Mode::CBC, Crypt::Mode::CTR, or Crypt::CBC β€” and yes, Crypt::CBC is the slower one 😭

🌸 METHODS 🌸

unless noted otherwise, assume $c is an existing cipher object you made with new, like this:

my $c = Crypt::Cipher::IDEA->new($key);

πŸŽ€ new

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

# $key .... [binary string] key of an accepted length (see keysize, min_keysize, max_keysize)
# $rounds . [integer] optional, number of rounds (if supported by the cipher; croaks on invalid value)

so $key is a binary string of an accepted length β€” check keysize, min_keysize, and max_keysize for the deets. $rounds is optional, an integer, and it's the number of rounds if the cipher supports that. invalid value? it croaks. periodt πŸ’€

πŸ” encrypt

encrypts exactly one block of plaintext. the length of $plaintext must equal blocksize; otherwise it croaks. an empty string is accepted and returned unchanged. yes, literally unchanged 🫢

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

returns the encrypted block as a binary string (raw bytes) β€” no extra packaging, just the bytes, bestie.

πŸ”“ decrypt

decrypts exactly one block of ciphertext. the length of $ciphertext must equal blocksize; otherwise it croaks. an empty string is accepted and returned unchanged. same energy as encrypt, but reverse πŸ’…

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

returns the decrypted block as a binary string (raw bytes). raw. bytes. iconic.

πŸ”‘ keysize

just an alias for max_keysize, lowkey convenient.

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

🧱 blocksize

returns the cipher block size (in bytes). that's the unit, don't forget it ✨

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

πŸ“ max_keysize

returns the maximum key size (in bytes). big-key energy.

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

🧸 min_keysize

returns the minimum key size (in bytes). small but mighty.

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

πŸ” default_rounds

returns the cipher's default round count. the factory settings, basically πŸŽ€

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

🌈 SEE ALSO 🌈


cute sign-off time: this page is brought to you by perl v5.42.0, dated 2026-05-11, with footer energy reading Crypt::...er::IDEA(3) πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from