SHA question

Steffan Davies steff at steff.name
Wed Jan 13 13:17:29 GMT 2010


Dermot <paikkos at googlemail.com> wrote at 12:44 on 2010-01-13:

> Hi,
> 
> I have a lots of PDFs that I need to catalogue and I want to ensure
> the uniqueness of each PDF.  At LWP, Jonathan Rockway mentioned
> something similar with SHA1 and binary files.  Am I right in thinking
> that the code below is only taking the SHA on the name of the file and
> if I want to ensure uniqueness of the content I need to do something
> similar but as a file blob?

Yes, that looks about right. From a brief look at
http://perldoc.perl.org/Digest/SHA.html it appears that you may want 

my $sha = Digest::SHA->new(512);
$sha->addfile($n);
$digest=$sha->digest; # or hexdigest or b64digest

in your inner loop.

S




More information about the london.pm mailing list