BUG? sha-moduel returns same crc for different files

Neil Schemenauer nascheme at enme.ucalgary.ca
Sun Sep 17 17:54:21 CEST 2000


François Granger <francois.granger at free.fr> wrote:
>Thomas Weholt <thomas at cintra.no> wrote:
>
>> If this doesn't work I'll have to find another way of telling if files
>> are equal.
>
>I think that this is one of the function of the md5 algorithm. Have a
>look to the md5 module.

sha should do the same thing as md5 and is widely considered a
superior hash function.  Thomas, let's try to get this settled.
Try something like this:

    import sha
    data1 = open('file1.jpg', 'rb').read()
    data2 = open('file2.jpg', 'rb').read()
    print data1 == data2,
    print sha.new(data1).digest() == sha.new(data2).digest()
    
What do you get for output?  If you get "1 0" then you have most
likely found a bug.  If you get "1 1" then the data in the two
files really is the same.

  Neil



More information about the Python-list mailing list