1$OpenBSD: md5.pod,v 1.2 2023/05/16 11:53:01 espie Exp $ 2 3=head1 NAME 4 5OpenBSD::md5 - simple interface to sha256 digests 6 7=head1 SYNOPSIS 8 9 use OpenBSD::md5; 10 11 my $sha = OpenBSD::sha->new($filename); 12 $k->{$sha->key} = $filename; 13 14 my $ck2 = $sha->new($filename2); 15 16 if ($ck2->equals($sha)) { 17 ... 18 } 19 20 print $sha->stringize # provides a base64 representation 21 my $ck3 = $s->fromstring; # decodes both base64 and hex 22 23 24 25=head1 DESCRIPTION 26 27C<OpenBSD::md5> provides an object-oriented interface to cryptographic 28hashing facilities for use in the ports tree. 29 30In particular, it provides an abstraction to build crypto hashes from 31files, convert from and to text, and compare two checksums while 32keeping the user from making low-level decisions. 33 34The module itself is called C<OpenBSD::md5> for historical reasons, 35but the module only provides a C<OpenBSD::sha> class, that produces 36and writes sha256 digests. 37 38The C<OpenBSD::md5> class itself was removed a few years ago. 39 40=over 8 41 42=item $o = $class-E<gt>new($filename) 43 44create a new digest object from the contents of a file. 45 46=item $o = $class-E<gt>fromstring($string) 47 48create a new digest object from a string representation. 49 50=item $o2 = $o-E<gt>new($filename) / $o-E<gt>fromstring($string) 51 52create a new digest object C<$o2> of the same type as C<$o>. 53 54=item $o-E<gt>equals($o2) 55 56compare two digest objects. Returns true only if they match. 57 58=item $h{$o-E<gt>key} = ... 59 60return the actual digest as a binary string, for use as a key in hashing. 61 62=item $s = $o-E<gt>stringize 63 64convert the digest into a suitable text representation. 65 66=item $o-E<gt>write($fh) 67 68writes an appropriate digest annotation on a packing-list filehandle 69(see L<OpenBSD::PackingList(3p)> and L<pkg_create(1)>). 70 71=back 72 73=head1 SEE ALSO 74 75L<cksum(1)> , 76L<Digest::SHA(3p)> , 77L<Mime::Base64(3p)> 78