Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Calculate CRC32 checksums (like SFVs) (http://www.programmingforums.org/showthread.php?t=22881)

dezza Jul 4th, 2009 5:09 PM

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!


All times are GMT -5. The time now is 3:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC