View Single Post
Old Jul 4th, 2009, 5:09 PM   #1
dezza
Newbie
 
dezza's Avatar
 
Join Date: Mar 2005
Location: Denmark
Posts: 24
Rep Power: 0 dezza is on a distinguished road
Send a message via ICQ to dezza Send a message via MSN to dezza
Calculate CRC32 checksums (like SFVs)

import binascii
def getCRC(filename):
     filedata = open(filename).read()
     return binascii.crc32(filedata)

So far i've got this and it returns something like:

-2087276233

Someone told me that I had to use struct.pack or struct.unpack to change it to hex values.

I am not sure which type to convert to and would like some explanation to understand fully instead of coding in blind.

The final result should show the same CRC32 value as if you packed the file in WinRAR, checked it with the numerous SFV-checkers or whatever.

A link just in case:
http://docs.python.org/library/struct.html

Thanks alot in advance!
__________________
Come in and have a talk!
#programmingforums @ Freenode


Folding@Home Stats
dezza is offline   Reply With Quote