From b9bf3455296d4caec842b0cf2dcfc7cc3ed74036 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 4 Aug 2017 13:52:25 +1200 Subject: Allow choosing another SHA alg --- checkem | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'checkem') diff --git a/checkem b/checkem index ba7c1bd..51c56df 100755 --- a/checkem +++ b/checkem @@ -38,6 +38,11 @@ my %STATS = ( size => 7, ); +# Figure out the SHA algorithm to use; defaults to sha256, but can be overriden +# by setting CHECKEM_ALG in the environment to e.g. "sha1", which is slightly +# faster but technically broken in practice since early 2017 +my $alg = $ENV{CHECKEM_ALG} // 'sha256'; + # Start a hash of filesizes to file names/stats... my %sizes; @@ -76,8 +81,9 @@ FS: for my $fs ( grep { @{$_} > 1 } values %sizes ) { $inos{$dev}{$ino} = $f; } - # Files still the same size and not hard linked, group by digest - $dig //= Digest::SHA->new('sha256'); + # Files still the same size and not hard linked, group by digest; + # create the digest object if it isn't already defined + $dig //= Digest::SHA->new($alg); $dig->addfile( $f->{fn} ); push @{ $sums{ $dig->digest() } }, $f; } -- cgit v1.2.3