Calculate sha1 hash of a binary file

LaundroMat Laundro at gmail.com
Thu Aug 7 17:24:35 CEST 2008


On Aug 7, 2:22 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> LaundroMat <Laun... at gmail.com> writes:
> > Would it be wise to calculate the hash value based on say for instance
> > the first Mb? Is there a much larger chance of collusion this way (I
> > suppose not). If it's helpful, the files would primarily be media
> > (video) files.
>
> The usual purpose of using this type of hash is to detect corruption
> and/or tampering.  So you want to hash the whole file, not just part
> of it.  If you're not worried about intentional tampering, md5 should
> be somewhat faster than sha, but there are some attacks against it
> and you shouldn't use it for high security applications where you
> want security against forgery.  It should still have almost no chance
> of accidental collisions.

Well, what I really intend to do is store the file hashes, in order to
be able to recognise the files later on when they are stored on
another location, and under another filename. It's not so much
tampering I'm concerned with.






More information about the Python-list mailing list