Server IP : 85.214.239.14 / Your IP : 18.188.162.87 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/2/root/proc/2/root/proc/3/cwd/usr/share/perl/5.36.0/Digest/ |
Upload File : |
package Digest::file; use strict; use warnings; use Exporter (); use Carp qw(croak); use Digest (); our $VERSION = "1.20"; our @ISA = qw(Exporter); our @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 @_; open( my $fh, "<", $file ) || croak("Can't open '$file': $!"); binmode($fh); my $ctx = Digest->new(@_); $ctx->addfile($fh); close($fh); 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"; } =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>