9 use vars qw($VERSION @ISA @EXPORT_OK);
13 @EXPORT_OK = qw(digest_file_ctx digest_file digest_file_hex digest_file_base64);
17 croak("No digest algorithm specified") unless @_;
19 open(F, $file) || croak("Can't open '$file': $!");
21 my $ctx = Digest->new(@_);
28 digest_file_ctx(@_)->digest;
32 digest_file_ctx(@_)->hexdigest;
35 sub digest_file_base64 {
36 digest_file_ctx(@_)->b64digest;
45 Digest::file - Calculate digests of files
49 # Poor mans "md5sum" command
50 use Digest::file qw(digest_file_hex);
52 print digest_file_hex($_, "MD5"), " $_\n";
57 This module provide 3 convenience functions to calculate the digest
58 of files. The following functions are provided:
62 =item digest_file( $file, $algorithm, [$arg,...] )
64 This function will calculate and return the binary digest of the bytes
65 of the given file. The function will croak if it fails to open or
68 The $algorithm is a string like "MD2", "MD5", "SHA-1", "SHA-512".
69 Additional arguments are passed to the constructor for the
70 implementation of the given algorithm.
72 =item digest_file_hex( $file, $algorithm, [$arg,...] )
74 Same as digest_file(), but return the digest in hex form.
76 =item digest_file_base64( $file, $algorithm, [$arg,...] )
78 Same as digest_file(), but return the digest as a base64 encoded