I am writing a perl script to take the SHA256SUM of every image file in a directory. The problem is that the SHA256SUM created by perl is different than the one created by the straight sha256sum utility from the command line.
The perl script returns hashes much quicker than the command line, leading me to believe the image files are not actually being used, but some other value (like their names for instance).
I am using "strict" and "warnings", and no errors are being returned.
PHP Code:
use Digest::SHA;
# Code Omitted
opendir(my $dh, $STARTING_DIRECTORY) or die "Cannot open directory: $!";
while (readdir $dh)
{
# Strip out the "." and the ".."
unless ($_ eq '.' or $_ eq '..')
{
# Wrap up the filename for convenience
# It's equal to the absolute path to the file
my $absolute = "$STARTING_DIRECTORY$_";
# Calculate SHA256SUM
my $digest = Digest::SHA->new(256);
$digest->add($absolute);
my $hash = $digest->hexdigest();
print $hash, " $_\n";
}
# Code Omitted
Because these are image files, I do not need them to be read line-by-line, only in one piece, like the command line utility does it. How can I accomplish this?