| | |
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 |
address aliased anydbm app bash beginner bits calling casino changecolor cipher clear conversion coordinates corners count cturtle curves definedlines development dictionary digital dynamic events examples excel external feet file float format function gui handling hints homework iframe images import input java keycontrol line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable web-scrape whileloop word wxpython xlwt






