SHA question

James Laver james.laver at gmail.com
Wed Jan 13 14:06:34 GMT 2010


On Wed, Jan 13, 2010 at 1:46 PM, Dermot <paikkos at googlemail.com> wrote:
> 2010/1/13 Roger Burton West <roger at firedrake.org>:
>
>>>I am using it in a perl class
>>
>> So I won't point out the implications, but there's an obvious one which
>> will make your life easier.
>
> You can't leave me hanging there....
> Dp.
>

Well, there are a few things...

Firstly, you are indeed just hashing the filename, not the file contents.

Secondly, you're using Digest::SHA directly. The Digest:: series of
modules are meant to be used through the 'Digest' interface as in the
example Steffan gave. Doing this will make your life easier in most
cases (by providing a standard interface across almost all digest
algorithms and making it easy to switch (though ::Whirlpool disobeys
the rules of the interface :/ )) and provides the handy addfile method
you're looking for.

Thirdly, be aware of what hashing guarantees. It does *not* guarantee
uniqueness, it just gives you a very low chance that two files with
the same hash are different. It does guarantee that files with
different hashes are different, though.

Lastly, as regards on-topicness, Perl is definitely off-topic. Beer,
Pies, Dim Sum and Buffy are on-topic.*

On topic: Buffy eating a dim sum pie and washing it down with beer.

--James
* But you can still post perl here.


More information about the london.pm mailing list