Crypt::...::SHAKE(3)
okay bestie, this is the Crypt::...::SHAKE(3) page from the User Contributed Perl Documentation, and it's about to be your new fave. no cap. π
π NAME π
Crypt::Digest::SHAKE β hash functions SHAKE128, SHAKE256 from the SHA3 family. iconic behavior, literally.
β¨ SYNOPSIS β¨
use Crypt::Digest::SHAKE;
my $d = Crypt::Digest::SHAKE->new(128);
$d->add('any data');
my $part1 = $d->done(100); # 100 raw bytes
my $part2 = $d->done(100); # another 100 raw bytes
#...
# or absorb input from a file instead
my $file_d = Crypt::Digest::SHAKE->new(128);
$file_d->addfile('filename.dat');
my $file_part1 = $file_d->done(100);
π¦ DESCRIPTION π¦
So Crypt::Digest::SHAKE gives you an interface to the SHA3 family's sponge function SHAKE. sponge function era, honestly.
It's an XOF (extendable output function). Feed input with add() / addfile(), then read output with one or more done($len) calls. After the first done(), treat the object as being in output mode: do not call add() again on that state. Use reset() or a new object to start hashing a new message. that part matters, bestie.
πΈ METHODS πΈ
Unless noted otherwise, assume $d is an existing SHAKE object created via new, for example:
my $d = Crypt::Digest::SHAKE->new(128);
π new π
Cute little constructor moment:
my $d = Crypt::Digest::SHAKE->new($num);
# $num ... [integer] 128 or 256 (selects SHAKE128 or SHAKE256)
$num is an integer: 128 or 256, and it selects SHAKE128 or SHAKE256. slay.
π clone π
Clone call, zero drama:
my $d2 = $d->clone();
π§ reset π§
Reset call:
$d->reset();
π add π
Appends data to the message. Returns the object itself (for chaining) β yes bestie, chaining is the vibe.
Each argument is converted to bytes using Perl's usual scalar stringification. Defined scalars, including numbers and string-overloaded objects, are accepted. undef is treated as an empty string and may emit Perl's usual "uninitialized value" warning. keep that in mind, okay?
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
π addfile π
Reads the file content and appends it to the message. Returns the object itself (for chaining). file absorption era.
$d->addfile('filename.dat');
#or
my $filehandle = ...; # existing binary-mode filehandle
$d->addfile($filehandle);
π₯ done π₯
Returns $len bytes of output as a binary string. Can be called repeatedly to stream an unlimited amount of output from the same absorbed input. The $len argument is required and must be a positive integer. Single done() calls are limited to 1,000,000,000 bytes, but the recommended way to read large output is to call done() repeatedly in 10 MB chunks.
After the firstdone()call the object is in output mode. Callingadd()in this state croaks; usereset()or create a new object to hash a different message. do not skip this warning.
my $result_raw = $d->done($len);
# can be called multiple times; $len is the number of output bytes to read
# after the first done(), add() croaks until you call reset()
π SEE ALSO π
CryptX,Crypt::Digest<https://csrc.nist.gov/pubs/fips/202/final>
xoxo, your fave manual π β from the User Contributed Perl Documentation, perl v5.42.0, dated 2026-05-11. periodt.
π¦ where this page comes from
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms