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

# NAME

OpenBSD::md5 - simple interface to sha256 digests

# SYNOPSIS

        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

# DESCRIPTION

"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)).

# SEE ALSO

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

2023-05-16 | perl v5.40.1