| | |
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 |
abrupt alarm ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog cx-freeze data decimals dictionaries dictionary directory dynamic error examples exe file float format function gnu graphics gui halp heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite statistics string strings sudokusolver sum table terminal text thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia write wxpython xlib






