CAST5_PP(3)
π CAST5_PP β bestie edition π
okay so this is Crypt::CAST5_PP, a whole block cipher written in pure Perl β like, no C, no XS, just vibes and pure Perl. It's part of the User Contributed Perl Documentation, and yes she's giving "I read the RFC so you don't have to" energy. π§β¨
β¨ SYNOPSIS β¨
use Crypt::CBC;
my $crypt = Crypt::CBC->new({
key => "secret key",
cipher => "CAST5_PP",
});
my $message = "All mimsy were the borogoves";
my $ciphertext = $crypt->encrypt($message);
print unpack("H*", $ciphertext), "\n";
my $plaintext = $crypt->decrypt($ciphertext);
print $plaintext, "\n";
like literally just plug it into Crypt::CBC and go off, she handles the rest π
πΈ DESCRIPTION πΈ
This module gives you a pure Perl implementation of the CAST5 block cipher. CAST5 is also known as CAST-128 (same girl, two names, iconic). She's a product of the CAST design procedure, developed by C. Adams and S. Tavares.
And the best part?? The CAST5 cipher is available royalty-free. no licensing drama, no "please pay us", just free. periodt. π
π FUNCTIONS π
β blocksize
Returns the CAST5 block size, which is 8 bytes. This function exists so that Crypt::CAST5_PP can work with Crypt::CBC β it's basically the compatibility bestie. π«Ά
β keysize
Returns the maximum CAST5 key size, which is 16 bytes. that's the ceiling, bestie, don't try to go bigger.
β new
$cast5 = Crypt::CAST5_PP->new($key);
Create a new encryption object β¨ If the optional key parameter is given, it gets passed straight to the init() function. so like, she's already ready to go if you hand her a key.
β init
$cast5->init($key);
Set or change the encryption key that's gonna be used. The key must be from 40 bits (5 bytes) to 128 bits (16 bytes) in length. π
heads up: if the key you use is 80 bits or less, encryption and decryption will be somewhat faster. small key, speedy girl. πβοΈπ¨
It is best for the key to be random binary data, not something printable like a password. If you've got a password, run it through a message digest function first to turn it into a proper encryption key β see Digest::SHA1 or Digest::MD5 for that. π
also ngl,Crypt::CBCruns the given"key"through MD5 to get the actual encryption key. so that's happening whether you think about it or not. π
β encrypt
$ciphertext = $cast5->encrypt($plaintext);
Encrypt a block of plaintext using the current encryption key, and return the corresponding ciphertext. The input must be 8 bytes long, and the output has the same length. no more, no less. πβ¨
β οΈ ok so listen: the encryption here is in ECB mode, which means it encrypts each block independently. that can leave you vulnerable to dictionary attacks, so it's generally best to use some form of chaining between blocks β see Crypt::CBC for that. don't be the girl who raw-dogs ECB, we're better than that. π
β decrypt
$plaintext = $cast5->decrypt($ciphertext);
Decrypt the ciphertext and return the corresponding plaintext. the reverse of the above, as one does. π¦
π LIMITATIONS π
Always produces untainted output, even if the input is tainted β because that's what perl's pack() function does. not her choice, not her fault, that's just how pack() moves. π
π SEE ALSO π
RFC 2144, "The CAST-128 Encryption Algorithm", C. Adams, May 1997Crypt::CBC
π AUTHOR π
Bob Mathews, <bobmathews@alumni.calpoly.edu>
π COPYRIGHT π
Copyright (c) 2006 Bob Mathews. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bestie that's the whole page, you're officially CAST5 literate, slay πβ¨ This was perl v5.42.0, dated 2025-07-25, filed under CAST5_PP(3) β go forth and encrypt responsibly, ily ππ¦
π¦ where this page comes from
- fedora 43: perl-Crypt-CAST5_PP 1.04-48.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms