Compute a CRC32C (Castagnoli) which uses the generator polynomial 1EDC6F41h following Rocksoft Model CRC Algorithm in Python

牧云@^-^@ 提交于 2019-12-13 09:09:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!