lib/Devel/SelfStubber.t See if Devel::SelfStubber works
lib/diagnostics.pm Print verbose diagnostics
lib/diagnostics.t See if diagnostics.pm works
+lib/Digest/Changes Digest changelog
lib/Digest/base.pm Digest extensions
+lib/Digest/file.pm Digest extensions
lib/Digest.pm Digest extensions
lib/Digest/t/base.t See if Digest extensions work
lib/Digest/t/digest.t See if Digest extensions work
+lib/Digest/t/file.t See if Digest extensions work
lib/DirHandle.pm like FileHandle only for directories
lib/DirHandle.t See if DirHandle works
lib/dotsh.pl Code to "dot" in a shell script
use strict;
use vars qw($VERSION %MMAP $AUTOLOAD);
-$VERSION = "1.08";
+$VERSION = "1.10";
%MMAP = (
"SHA-1" => ["Digest::SHA1", ["Digest::SHA", 1], ["Digest::SHA2", 1]],
--- /dev/null
+2004-11-08 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.10
+
+ Added Digest::file module which provide convenience functions
+ that calculate digests of files.
+
+
+
+2004-11-05 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.09
+
+ Fix trivial documentation typo.
+
+
+
+2004-04-29 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.08
+
+ Make Digest->new("CRC-16"), Digest->new("CRC-32") and
+ Digest->new("CRC-CCITT") work.
+ Patch by Oliver Maul <oliver@maul.tv>.
+
+
+
+2004-04-25 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.07
+
+ Updated benchmark.
+
+
+
+2004-04-01 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.06
+
+ Added MIME::Base64 dependency.
+
+ Minor doc tweak.
+
+
+
+2003-12-01 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.05
+
+ Drop Digest::MD5 dependency. Avoids circular dependency
+ now that Digest::MD5 depend on this package to inherit
+ Digest::base.
+
+ Included a section about digest speed with benchmark
+ results for some implementations of this API.
+
+
+
+2003-11-29 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.04
+
+ Doc tweaks to unconfuse search.cpan.org.
+
+
+
+2003-11-28 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.03
+
+ Added add_bits() method as requested by the
+ Digest::SHA author Mark Shelor.
+
+ Added Digest::base class that Digest implementations
+ can use to get default implementations of addfile(),
+ add_bits(), hexdigest() and b64digest().
+
+ Digest->new("SHA-256") and similar should work now
+ given that you have either Digest::SHA or Digest::SHA2
+ installed.
+
+
+
+2003-01-18 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.02
+
+ Sync up with version bundled with perl-5.8.
+ Patch by Jarkko Hietaniemi <jhi@iki.fi>.
+
+ Override INSTALLDIRS for 5.8 as suggested by
+ Guido Ostkamp <Guido.Ostkamp@t-online.de>.
+
+
+
+2003-01-04 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.01
+
+ Document the clone() method.
+
+
+
+2001-03-13 Gisle Aas <gisle@ActiveState.com>
+
+ Release 1.00
+
+ Broken out of the Digest-MD5-2.12 distribution and made into
+ a separate dist.
Digest::base - Digest base class
-=head1 SYNPOSIS
+=head1 SYNOPSIS
package Digest::Foo;
use base 'Digest::base';
--- /dev/null
+package Digest::file;
+
+use strict;
+
+use Exporter ();
+use Carp qw(croak);
+use Digest ();
+
+use vars qw($VERSION @ISA @EXPORT_OK);
+
+$VERSION = "0.01";
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(digest_file_ctx digest_file digest_file_hex digest_file_base64);
+
+sub digest_file_ctx {
+ my $file = shift;
+ croak("No digest algorithm specified") unless @_;
+ local *F;
+ open(F, $file) || croak("Can't open '$file': $!");
+ binmode(F);
+ my $ctx = Digest->new(@_);
+ $ctx->addfile(*F);
+ close(F);
+ return $ctx;
+}
+
+sub digest_file {
+ digest_file_ctx(@_)->digest;
+}
+
+sub digest_file_hex {
+ digest_file_ctx(@_)->hexdigest;
+}
+
+sub digest_file_base64 {
+ digest_file_ctx(@_)->b64digest;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Digest::file - Calculate digests of files
+
+=head1 SYNOPSIS
+
+ # Poor mans "md5sum" command
+ use Digest::file qw(digest_file_hex);
+ for (@ARGV) {
+ print digest_file_hex($_, "MD5"), " $_\n";e
+ }
+
+=head1 DESCRIPTION
+
+This module provide 3 convenience functions to calculate the digest
+of files. The following functions are provided:
+
+=over
+
+=item digest_file( $file, $algorithm, [$arg,...] )
+
+This function will calculate and return the binary digest of the bytes
+of the given file. The function will croak if it fails to open or
+read the file.
+
+The $algorithm is a string like "MD2", "MD5", "SHA-1", "SHA-512".
+Additional arguments are passed to the constructor for the
+implementation of the given algorithm.
+
+=item digest_file_hex( $file, $algorithm, [$arg,...] )
+
+Same as digest_file(), but return the digest in hex form.
+
+=item digest_file_base64( $file, $algorithm, [$arg,...] )
+
+Same as digest_file(), but return the digest as a base64 encoded
+string.
+
+=back
+
+=head1 SEE ALSO
+
+L<Digest>
--- /dev/null
+#!perl -w
+
+use Test qw(plan ok);
+plan tests => 5;
+
+{
+ package Digest::Foo;
+ require Digest::base;
+ use vars qw(@ISA $VERSION);
+ @ISA = qw(Digest::base);
+
+ sub new {
+ my $class = shift;
+ my $str = "";
+ bless \$str, $class;
+ }
+
+ sub add {
+ my $self = shift;
+ $$self .= join("", @_);
+ return $self;
+ }
+
+ sub digest {
+ my $self = shift;
+ return sprintf "%04d", length($$self);
+ }
+}
+
+use Digest::file qw(digest_file digest_file_hex digest_file_base64);
+
+my $file = "test-$$";
+die if -f $file;
+open(F, ">$file") || die "Can't create '$file': $!";
+binmode(F);
+print F "foo\0\n";
+close(F) || die "Can't write '$file': $!";
+
+ok(digest_file($file, "Foo"), "0005");
+ok(digest_file_hex($file, "Foo"), "30303035");
+ok(digest_file_base64($file, "Foo"), "MDAwNQ");
+
+unlink($file) || warn "Can't unlink '$file': $!";
+
+ok(eval { digest_file("not-there.txt", "Foo") }, undef);
+ok($@);