file.pm

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PM 代码 · 共 86 行

PM
86
字号
package Digest::file;use strict;use Exporter ();use Carp qw(croak);use Digest ();use vars qw($VERSION @ISA @EXPORT_OK);$VERSION = "1.00";@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 NAMEDigest::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";  }=head1 DESCRIPTIONThis module provide 3 convenience functions to calculate the digestof files.  The following functions are provided:=over=item digest_file( $file, $algorithm, [$arg,...] )This function will calculate and return the binary digest of the bytesof the given file.  The function will croak if it fails to open orread the file.The $algorithm is a string like "MD2", "MD5", "SHA-1", "SHA-512".Additional arguments are passed to the constructor for theimplementation 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 encodedstring.=back=head1 SEE ALSOL<Digest>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?