问题
I did explore Crcmod python library but couldnt use it as my gen poly- 0x1EDC6F41 is not considered a 32 bit poly :( Is there a way to tweak it or any other python lib that I can use to do this?
Name : "CRC-32C"
Width : 32
Poly : 1EDC6F41h
Init : FFFFFFFFh
RefIn : True
RefOut : True
XorOut : FFFFFFFFh
Check : E3069283h
Here is what I tried-
import crcmod
f = crcmod.mkCrcFun(0x1EDC6F41)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\Lib\site-packages\crcmod\crcmod.py", line 281, in mkCrcFun
(sizeBits, initCrc, xorOut) = _verifyParams(poly, initCrc, xorOut)
File "C:\Python27\Lib\site-packages\crcmod\crcmod.py", line 405, in _verifyParams
sizeBits = _verifyPoly(poly)
File "C:\Python27\Lib\site-packages\crcmod\crcmod.py", line 302, in _verifyPoly
raise ValueError(msg)
ValueError: The degree of the polynomial must be 8, 16, 24, 32 or 64
回答1:
Usually CRC polynomials are specified without the most significant bit, which is always 1. But it looks like the crcmod library expects this bit to be specified. So you should use the polynomial 0x11EDC6F41
. (adding a 1 to the left).
来源:https://stackoverflow.com/questions/33932170/compute-a-crc32c-castagnoli-which-uses-the-generator-polynomial-1edc6f41h-foll