NAME

Mail::DKIM2::BodyHasher - the body hash of a message, streamed

SYNOPSIS

my $hasher = Mail::DKIM2::BodyHasher->new(Algs => ['sha256'])
             ->load($fh);
my $mi = Mail::DKIM2::MessageInstance->calculate($header_block,
    undef, BodyHash => $hasher->body_hashes);

DESCRIPTION

The -07 section 6.1 body hash of a message, as Mail::DKIM2::MessageInstance::body_digest_raw computes it, from a message fed through PRINT and CLOSE (or load) in pieces of any size. The body is hashed as it arrives and never held: at most a megabyte of it is kept at a time. The header fields are parsed as the Signer and Verifier parse them and are in $self->{headers}.

It is for a host that holds a large message in a file and needs its body hash for MessageInstance->calculate (BodyHash) or MessageInstance->verify (BodyHashes), which then need only the header block.

CONSTRUCTOR

new(%options)

Algs is an array reference of hash algorithm names, default ['sha256']; an unknown one croaks.

METHODS

PRINT, CLOSE and load are Mail::DKIM2::HeaderParser's.

body_hashes()

After CLOSE: a new hash reference of algorithm name to base64 body hash, in the form calculate's BodyHash and verify's BodyHashes take.

body_hash([$alg])

After CLOSE: the base64 body hash by $alg (default sha256), which must have been among Algs.

SUBCLASS INTERFACE

known_options(), init(), finish_header(), finish_body()

As for Mail::DKIM2::HeaderParser.

AUTHOR

Bron Gondwana <brong@fastmailteam.com>

COPYRIGHT AND LICENSE

Copyright (c) 2026 Fastmail Pty Ltd. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.