![]() |
| ||
| Calculate CRC32 checksums (like SFVs) So far i've got this and it returns something like: -2087276233 import binascii 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! |
| ||
| Re: Calculate CRC32 checksums (like SFVs) Post your code! Check your variables are properly set signed/unsigned! |
| ||
| Re: Calculate CRC32 checksums (like SFVs) Quote:
import binascii |
| ||
| Re: Calculate CRC32 checksums (like SFVs) You may want to try a binary file read. |
| ||
| Re: Calculate CRC32 checksums (like SFVs) Quote:
|
| ||
| Re: Calculate CRC32 checksums (like SFVs) http://dev.jmoiron.net/code/html/cksum.py.html Can I use this code example to write a more simple approach? I would prefer it in a single function, but the classes and etc. confuses me, I think he should simplify his code, it also gives a deprecation warning .. |
| ||
| Re: Calculate CRC32 checksums (like SFVs) I instead used a crc32.c script for use with subprocess .. Faster, and easier .. |
| ||
| Re: Calculate CRC32 checksums (like SFVs) Quote:
openmethod here, and the answer will reveal itself. |
| ||
| Re: Calculate CRC32 checksums (like SFVs) I have tried both open(filename, 'r') and open(filename, 'rb') I can get the file loaded into a string and then try print binascii.crc32(file-in-string) Still just gives me negative integers, what I want is the 8-char hexvalue. |
| ||
| Re: Calculate CRC32 checksums (like SFVs) Quote:
Use string formatting to print the hex value, just as the example in the docs shows you. |
| All times are GMT -4. The time now is 9:15 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC