Digest...ltiHash(3pm)

πŸ“¦
version 0.11 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 πŸ™ˆ)
  • add
  • digest β€” Compute the hash by calling digest on all of the subhashes, splitting the result up into width sized 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 to new in 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