.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Crypt::Digest::SHAKE 3" .TH Crypt::Digest::SHAKE 3 2026-05-12 "perl v5.42.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Crypt::Digest::SHAKE \- Hash functions SHAKE128, SHAKE256 from SHA3 family .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Crypt::Digest::SHAKE; \& \& my $d = Crypt::Digest::SHAKE\->new(128); \& $d\->add(\*(Aqany data\*(Aq); \& 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(\*(Aqfilename.dat\*(Aq); \& my $file_part1 = $file_d\->done(100); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Provides an interface to the SHA3\*(Aqs sponge function SHAKE. .PP This is an XOF (extendable output function). Feed input with \f(CWadd()\fR / \&\f(CWaddfile()\fR, then read output with one or more \f(CWdone($len)\fR calls. After the first \f(CWdone()\fR, treat the object as being in output mode: do not call \f(CWadd()\fR again on that state. Use \f(CWreset()\fR or a new object to start hashing a new message. .SH METHODS .IX Header "METHODS" Unless noted otherwise, assume \f(CW$d\fR is an existing SHAKE object created via \&\f(CW\*(C`new\*(C'\fR, for example: .PP .Vb 1 \& my $d = Crypt::Digest::SHAKE\->new(128); .Ve .SS new .IX Subsection "new" .Vb 2 \& my $d = Crypt::Digest::SHAKE\->new($num); \& # $num ... [integer] 128 or 256 (selects SHAKE128 or SHAKE256) .Ve .SS clone .IX Subsection "clone" .Vb 1 \& my $d2 = $d\->clone(); .Ve .SS reset .IX Subsection "reset" .Vb 1 \& $d\->reset(); .Ve .SS add .IX Subsection "add" Appends data to the message. Returns the object itself (for chaining). .PP Each argument is converted to bytes using Perl\*(Aqs usual scalar stringification. Defined scalars, including numbers and string\-overloaded objects, are accepted. \f(CW\*(C`undef\*(C'\fR is treated as an empty string and may emit Perl\*(Aqs usual "uninitialized value" warning. .PP .Vb 3 \& $d\->add(\*(Aqany data\*(Aq); \& #or \& $d\->add(\*(Aqany data\*(Aq, \*(Aqmore data\*(Aq, \*(Aqeven more data\*(Aq); .Ve .SS addfile .IX Subsection "addfile" Reads the file content and appends it to the message. Returns the object itself (for chaining). .PP .Vb 4 \& $d\->addfile(\*(Aqfilename.dat\*(Aq); \& #or \& my $filehandle = ...; # existing binary\-mode filehandle \& $d\->addfile($filehandle); .Ve .SS done .IX Subsection "done" Returns \f(CW$len\fR bytes of output as a binary string. Can be called repeatedly to stream an unlimited amount of output from the same absorbed input. The \&\f(CW$len\fR argument is required and must be a positive integer. Single \&\f(CWdone()\fR calls are limited to 1,000,000,000 bytes, but the recommended way to read large output is to call \f(CWdone()\fR repeatedly in 10 MB chunks. .PP After the first \f(CWdone()\fR call the object is in output mode. Calling \&\f(CWadd()\fR in this state croaks; use \f(CWreset()\fR or create a new object to hash a different message. .PP .Vb 3 \& 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() .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .IP \(bu 4 CryptX, Crypt::Digest .IP \(bu 4