$OpenBSD: OpenBSD::md5.pod,v 1.1 2012/01/15 14:16:16 espie Exp $ =head1 NAME OpenBSD::md5 - simple interface to md5 and sha256 digests =head1 SYNOPSIS use OpenBSD::md5; my $md5 = OpenBSD::md5->new($filename); $k->{$md5->key} = $filename; my $ck2 = $md5->new($filename2); if ($ck2->equals(md5)) { ... } print $md5->stringize # provides an hex representation my $ck3 = OpenBSD::sha->new($filename); !$ck3->equals($ck2); # comparing is okay, but will never match my $s = $ck3->stringize; # base64 representation my $ck4 = $s->fromstring; # decodes both base64 and hex =head1 DESCRIPTION C 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. There are two classes, C and C which provide the same facilities, respectively for md5 and sha256 digests. The module itself is called C for historical reasons. Support for md5 digests is there for legacy reasons, all new code should produce and write sha256 digests only. =over 8 =item $o = $class-Enew($filename) create a new digest object from the contents of a file. =item $o = $class-Efromstring($string) create a new digest object from a string representation. =item $o2 = $o-Enew($filename) / $o-Efromstring($string) create a new digest object C<$o2> of the same type as C<$o>. This can be used to compare a file against an existing digest, which may well be of md5 type in very old packages. Even though the use of md5 is deprecated, checking md5 checksums is still slightly better than nothing... =item $o-Eequal($o2) compare two digest objects. Returns true only if they're of the same type and they match. =item $h{$o-Ekey} = ... return the actual digest as a binary string, for use as a key in hashing. =item $s = $o-Estringize convert the digest into a suitable text representation. =item $o-Ewrite($fh) writes an appropriate digest annotation on a packing-list filehandle (see L and L). =back =head1 SEE ALSO L , L , L , L