2

I tried to calculate ANSI CRC16 polynomial (0x8005) using this code

import crcmod
crc16 = crcmod.mkCrcFun(0x8005, 0xffff, True)

but I got this error message

ValueError: The degree of the polynomial must be 8, 16, 24, 32 or 64

Gray
  • 267
  • 1
  • 6
  • 12
  • I got the same error message " ValueError: The degree of the polynomial must be 8, 16, 24, 32 or 64" – Gray Jul 20 '14 at 13:46
  • It seems like `0x8005` is **not** the valid representation for CRC16. That's what the error is telling you: `0x8005` represents a CRC that has an unsupported degree. Change it to something meaningful. – Bakuriu Jul 20 '14 at 13:52
  • I am trying to calculate crc16 for ext4 file system and based on the docs it uses 0x8005 https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums#Block_Groups – Gray Jul 20 '14 at 14:10

1 Answers1

7

There is an implied 1 at the beginning of 0x8005

crcmod expects you to provide the 1 explicitly

import crcmod
crc16 = crcmod.mkCrcFun(0x18005, 0xffff, True)
John La Rooy
  • 295,403
  • 53
  • 369
  • 502