diff options
Diffstat (limited to 'Master/tlpkg/TeXLive/TLCrypto.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLCrypto.pm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Master/tlpkg/TeXLive/TLCrypto.pm b/Master/tlpkg/TeXLive/TLCrypto.pm index 2b0203ad348..a0fab47aa7d 100644 --- a/Master/tlpkg/TeXLive/TLCrypto.pm +++ b/Master/tlpkg/TeXLive/TLCrypto.pm @@ -7,11 +7,23 @@ package TeXLive::TLCrypto; use Digest::MD5; -use Digest::SHA; use TeXLive::TLConfig; use TeXLive::TLUtils qw(debug ddebug win32 which platform conv_to_w32_path); +# try to load Digest::SHA, and if that fails, use our own slow modules +my $dig; +eval { + require Digest::SHA; + Digest::SHA->import('sha512_hex'); + $dig = Digest::SHA->new(512); +}; +if ($@) { + require TeXLive::SHA; + TeXLive::SHA->import('sha512_hex'); + $dig = TeXLive::SHA->new(512); +} + my $svnrev = '$Revision: 40650 $'; my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown"; sub module_revision { return $_modulerevision; } @@ -70,7 +82,7 @@ sub tlchecksum { if (-r $file) { open(FILE, $file) || die "open($file) failed: $!"; binmode(FILE); - my $cshash = Digest::SHA->new(512)->addfile(*FILE)->hexdigest; + my $cshash = $dig->new(512)->addfile(*FILE)->hexdigest; close(FILE); return $cshash; } else { @@ -81,7 +93,7 @@ sub tlchecksum { sub tlchecksum_data { my ($data) = @_; - my $cshash = Digest::SHA->new(512)->add($data)->hexdigest; + my $cshash = $dig->new(512)->add($data)->hexdigest; return $cshash; } @@ -117,7 +129,7 @@ Return full and short digests of C<$str>, respectively. =cut -sub tldigest { return (Digest::SHA::sha512_hex(shift)); } +sub tldigest { return (sha512_hex(shift)); } sub tl_short_digest { return (Digest::MD5::md5_hex(shift)); } # emacs-page |