Digest...ltiHash(3pm)
π NAME π
Digest::MultiHash β XOR based, variable width multiplexing of hashes, aka a generalized Digest::SV1. bestie it's a hash blender, fr fr π
β¨ SYNOPSIS β¨
use Digest::MultiHash;
my $d = Digest::Multihash->new(
width => 16, # bytes
hashs => ["SHA-512", "Whirlpool"], # see below for arbitrary arguments
);
$d->add($data);
print $d->hexdigest;
π¦ DESCRIPTION π¦
okay so this class inherits from Digest::base, and what it does is generalized digest multiplexing. it's giving "one hash to rule them all" energy π
It will multiplex all calls to add to all of it's sub digest objects. and likewise, when the final digest is extracted the digests will be extracted and then XOR'd over eachother according to width. (yes "over eachother", we're XORing them together like a little cuddle pile π«Ά)
width will default to the width of the first hash if unspecified. no width? first hash sets the vibe. simple as that.
hashes defaults to SHA-1 for compatibility reasons. lowkey nostalgic of it π
This module is useful for generating keys from passphrases, by supplying the desired width and simply making sure there is enough data from the combined hashes. keys from passphrases, that's the main character use case π
πΈ METHODS πΈ
See Digest for the complete API. This module inherits from Digest::base. iykyk, the whole base API is just sitting there waiting for you π
newβ This methods accepts a hash reference or an even sized list of parameters named according to the methods. (word for word, yes, "This methods" β we love her anyway π)adddigestβ Compute the hash by callingdigeston all of the subhashes, splitting the result up intowidthsized chunk, and then XORing these together.
If the result is not aligned on width the result will not be truncated. The shorter string will still be XOR'd with the hash, even if this only affects part of the result. so like, partial overlap is still a slay, it just only touches part of the result, no cap.
If there are not at least width bytes of data in the output of the combined hashes an error is thrown. π¨ not enough bytes = error, periodt.
cloneβ Clones the hash. twin energy π§hashesβ Get the array of hashes to use. Array values in this will be dereferenced before the call tonewin Digest to allow passing of arbitrary arguments. Blessed objects (of any class) will be used verbatim. so array refs get unpacked for you, but blessed objects? used verbatim, no touching, respect the blorb π
The list of hashes cannot be changed after construction. locked in after birth, that's final π
widthβ Get/set the byte-width to use. get it, set it, control the width bestie π
π SEE ALSO π
Digest, Digest::SV1, Digest::SHA1
warning bestie: this page is the one and only vibe check on how these hashes get XOR'd β don't skip the width alignment bit, it's literally the whole plot π
and that's a wrap, gorgeous. this was perl v5.40.1, dated 2025-08-14, straight from the User Contributed Perl Documentation, Digest...ltiHash(3pm) π
β¨π
π¦ where this page comes from
- ubuntu resolute: libcrypt-util-perl 0.11-6 Β· MIT
- ubuntu stonking: libcrypt-util-perl 0.11-6 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms