| | |
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
- 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 grades for a student using if..else statements. (Java)
- 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 aliased anydbm app argv beginner bits calling casino cipher clear command conversion convert coordinates corners count csv cturtle cursor curves def definedlines development dynamic event events excel feet file float format frange function google handling homework i/o iframe input jaunty keyboard keycontrol lapse line linux list lists loan loop matching microphone mouse newb number numbers obexftp output parsing path prime programming projects py py2exe pygame pymailer pyopengl python random rational raw_input recursion recursive return searchingfile signal string strings tails text time tlapse tooltip tuple type ubuntu unicode url urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython xlwt






