diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-08-04 13:52:25 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-08-04 13:52:25 +1200 |
commit | b9bf3455296d4caec842b0cf2dcfc7cc3ed74036 (patch) | |
tree | 38b96cd38583bfdf56c9178cd6f4cbc4ea2625f8 /checkem | |
parent | Remove unneeded parens (diff) | |
download | checkem-b9bf3455296d4caec842b0cf2dcfc7cc3ed74036.tar.gz checkem-b9bf3455296d4caec842b0cf2dcfc7cc3ed74036.zip |
Allow choosing another SHA alg
Diffstat (limited to 'checkem')
-rwxr-xr-x | checkem | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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; } |