| | |
Calculate CRC32 checksums (like SFVs)
![]() |
•
•
Join Date: Jul 2009
Posts: 6
Reputation:
Solved Threads: 0
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!
-2087276233
Python Syntax (Toggle Plain Text)
import binascii def getCRC(filename): filedata = open(filename).read() return binascii.crc32(filedata)
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!
•
•
Join Date: Jul 2009
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
Post your code! Check your variables are properly set signed/unsigned!
python Syntax (Toggle Plain Text)
import binascii def getCRC(filename): filedata = open(filename).read() return binascii.crc32(filedata)
•
•
Join Date: Jul 2009
Posts: 6
Reputation:
Solved Threads: 0
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 ..
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 ..
•
•
•
•
Can you define this method? I am not sure I understand what you mean.
open method here, and the answer will reveal itself. •
•
•
•
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.
Use string formatting to print the hex value, just as the example in the docs shows you.
![]() |
Similar Threads
- calculate the grades for a student using if..else statements. (Java)
- Factorial Calculate (VB.NET)
- Verifying files against checksums (Windows Software)
- How do i calculate the frequency of elements in a chain node. (Java)
- calculate image property in javascript (JavaScript / DHTML / AJAX)
- Calculate the factorial of a number (Visual Basic 4 / 5 / 6)
Other Threads in the Python Forum
- Previous Thread: Hello
- Next Thread: How to perform a certain task using subprocess module?
| Thread Tools | Search this Thread |
accessdenied advanced apache application argv array beginner book change command converter countpasswordentry csv curved dan08 def dictionary dynamic edit enter event examples file float format function google gui homework import inches input jaunty java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric obexftp output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pygtk pyopengl python random recursion redirect remote return reverse scrolledtext session simple skinning software sprite statictext string strings syntax terminal text threading time tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable voip wordgame wxpython






