aboutsummaryrefslogtreecommitdiff
path: root/checkem
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-08-04 13:52:25 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-08-04 13:52:25 +1200
commitb9bf3455296d4caec842b0cf2dcfc7cc3ed74036 (patch)
tree38b96cd38583bfdf56c9178cd6f4cbc4ea2625f8 /checkem
parentRemove unneeded parens (diff)
downloadcheckem-b9bf3455296d4caec842b0cf2dcfc7cc3ed74036.tar.gz
checkem-b9bf3455296d4caec842b0cf2dcfc7cc3ed74036.zip
Allow choosing another SHA alg
Diffstat (limited to 'checkem')
-rwxr-xr-xcheckem10
1 files changed, 8 insertions, 2 deletions
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;
}