NAME

Mail::DKIM2::Digest - SHA-2 over message content, by OpenSSL where it can

SYNOPSIS

use Mail::DKIM2::Digest;

my $d = Mail::DKIM2::Digest->new('sha256');
$d->add($chunk) for @chunks;
my $raw = $d->digest;

my $raw = Mail::DKIM2::Digest::digest_data('sha512', $data);

DESCRIPTION

Every hash over message content (Message-Instance header and body hashes) goes through here. With Net::SSLeay installed it is OpenSSL's, which uses the CPU's SHA instructions where there are any (several times quicker than CryptX's on such a CPU); otherwise CryptX's. The digests are the same.

FUNCTIONS AND METHODS

new($alg)

sha256 or sha512; croaks on anything else. The object has add(@data) and digest() (once), as a Crypt::Digest object has.

add(@data)

Hashes more data; returns the object.

digest()

The raw digest. The object is finished with.

digest_data($alg, $data)

A function: the raw digest of $data.

backend()

openssl or cryptx: what new uses. $Mail::DKIM2::Digest::BACKEND set to either (locally) chooses; cryptx is used if OpenSSL's is not available.

openssl_available()

True if Net::SSLeay is installed and has OpenSSL's SHA-256 and SHA-512.

AUTHOR

Bron Gondwana <brong@fastmailteam.com>

COPYRIGHT AND LICENSE

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