1*8beddab0Sespie$OpenBSD: md5.pod,v 1.2 2023/05/16 11:53:01 espie Exp $ 26e49571cSdaniel 36e49571cSdaniel=head1 NAME 46e49571cSdaniel 56e49571cSdanielOpenBSD::md5 - simple interface to sha256 digests 66e49571cSdaniel 76e49571cSdaniel=head1 SYNOPSIS 86e49571cSdaniel 96e49571cSdaniel use OpenBSD::md5; 106e49571cSdaniel 116e49571cSdaniel my $sha = OpenBSD::sha->new($filename); 126e49571cSdaniel $k->{$sha->key} = $filename; 136e49571cSdaniel 146e49571cSdaniel my $ck2 = $sha->new($filename2); 156e49571cSdaniel 166e49571cSdaniel if ($ck2->equals($sha)) { 176e49571cSdaniel ... 186e49571cSdaniel } 196e49571cSdaniel 206e49571cSdaniel print $sha->stringize # provides a base64 representation 216e49571cSdaniel my $ck3 = $s->fromstring; # decodes both base64 and hex 226e49571cSdaniel 236e49571cSdaniel 246e49571cSdaniel 256e49571cSdaniel=head1 DESCRIPTION 266e49571cSdaniel 276e49571cSdanielC<OpenBSD::md5> provides an object-oriented interface to cryptographic 286e49571cSdanielhashing facilities for use in the ports tree. 296e49571cSdaniel 306e49571cSdanielIn particular, it provides an abstraction to build crypto hashes from 316e49571cSdanielfiles, convert from and to text, and compare two checksums while 326e49571cSdanielkeeping the user from making low-level decisions. 336e49571cSdaniel 346e49571cSdanielThe module itself is called C<OpenBSD::md5> for historical reasons, 356e49571cSdanielbut the module only provides a C<OpenBSD::sha> class, that produces 366e49571cSdanieland writes sha256 digests. 376e49571cSdaniel 386e49571cSdanielThe C<OpenBSD::md5> class itself was removed a few years ago. 396e49571cSdaniel 406e49571cSdaniel=over 8 416e49571cSdaniel 426e49571cSdaniel=item $o = $class-E<gt>new($filename) 436e49571cSdaniel 446e49571cSdanielcreate a new digest object from the contents of a file. 456e49571cSdaniel 466e49571cSdaniel=item $o = $class-E<gt>fromstring($string) 476e49571cSdaniel 486e49571cSdanielcreate a new digest object from a string representation. 496e49571cSdaniel 506e49571cSdaniel=item $o2 = $o-E<gt>new($filename) / $o-E<gt>fromstring($string) 516e49571cSdaniel 526e49571cSdanielcreate a new digest object C<$o2> of the same type as C<$o>. 536e49571cSdaniel 54*8beddab0Sespie=item $o-E<gt>equals($o2) 556e49571cSdaniel 566e49571cSdanielcompare two digest objects. Returns true only if they match. 576e49571cSdaniel 586e49571cSdaniel=item $h{$o-E<gt>key} = ... 596e49571cSdaniel 606e49571cSdanielreturn the actual digest as a binary string, for use as a key in hashing. 616e49571cSdaniel 626e49571cSdaniel=item $s = $o-E<gt>stringize 636e49571cSdaniel 646e49571cSdanielconvert the digest into a suitable text representation. 656e49571cSdaniel 666e49571cSdaniel=item $o-E<gt>write($fh) 676e49571cSdaniel 686e49571cSdanielwrites an appropriate digest annotation on a packing-list filehandle 696e49571cSdaniel(see L<OpenBSD::PackingList(3p)> and L<pkg_create(1)>). 706e49571cSdaniel 716e49571cSdaniel=back 726e49571cSdaniel 736e49571cSdaniel=head1 SEE ALSO 746e49571cSdaniel 756e49571cSdanielL<cksum(1)> , 766e49571cSdanielL<Digest::SHA(3p)> , 776e49571cSdanielL<Mime::Base64(3p)> 78