| | |
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 |
alarm app assignment avogadro beginner bluetooth character cipher cmd code customdialog cx-freeze data decimals dictionary directory dynamic error examples exe file float format function generator getvalue gnu graphics gui halp homework http ideas images import input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse number numbers output parsing path port prime programming projects push py2exe pygame pyglet pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh string strings sudokusolver terminal text threading time tlapse tuple tutorial ubuntu unicode url urllib urllib2 variable variables ventrilo vigenere web webservice wikipedia wxpython xlib






