OpenBSD manual page server

Manual Page Search Parameters

OpenBSD::md5(3p) Perl Programmers Reference Guide OpenBSD::md5(3p)

OpenBSD::md5 - simple interface to sha256 digests

    use OpenBSD::md5;
    my $sha = OpenBSD::sha->new($filename);
    $k->{$sha->key} = $filename;
    my $ck2 = $sha->new($filename2);
    if ($ck2->equals($sha)) {
         ...
    }
    print $sha->stringize # provides a base64 representation
    my $ck3 = $s->fromstring; # decodes both base64 and hex

"OpenBSD::md5" provides an object-oriented interface to cryptographic hashing facilities for use in the ports tree.

In particular, it provides an abstraction to build crypto hashes from files, convert from and to text, and compare two checksums while keeping the user from making low-level decisions.

The module itself is called "OpenBSD::md5" for historical reasons, but the module only provides a "OpenBSD::sha" class, that produces and writes sha256 digests.

The "OpenBSD::md5" class itself was removed a few years ago.

$o = $class->new($filename)
create a new digest object from the contents of a file.
$o = $class->fromstring($string)
create a new digest object from a string representation.
$o2 = $o->new($filename) / $o->fromstring($string)
create a new digest object $o2 of the same type as $o.
$o->equals($o2)
compare two digest objects. Returns true only if they match.
$h{$o->key} = ...
return the actual digest as a binary string, for use as a key in hashing.
$s = $o->stringize
convert the digest into a suitable text representation.
$o->write($fh)
writes an appropriate digest annotation on a packing-list filehandle (see OpenBSD::PackingList(3p) and pkg_create(1)).

cksum(1) , Digest::SHA(3p) , Mime::Base64(3p)

2023-05-16 perl v5.38.2