You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I find crc16 algorithms has many other polynomials.
In helper.py, crc16 function is:
"
def crc16(string, value=0):
"""
CRC-16 poly: p(x) = x16 + x15 + x**2 + 1
"""
crc16_table = []
for byte in range(256):
crc = 0
for bit in range(8):
if (byte ^ crc) & 1:
crc = (crc >> 1) ^ 0xa001 # polly
else:
crc >>= 1
byte >>= 1
crc16_table.append(crc)
for ch in string:
value = crc16_table[ord(ch) ^ (value & 0xff)] ^ (value >> 8)
return value
"
and I am not sure the funtion can be writen like this:
"
def crc16(string, value=0xa001):
"""
CRC-16 poly: p(x) = x16 + x15 + x**2 + 1
@:param value:
CRC-16 model
P_16 0xa001
P_CCITT 0x1021
P-DNP 0xa6bc
p_KERMIT 0x8408
P_SICK 0x8005
"""
crc16_table = []
for byte in range(256):
crc = 0
for bit in range(8):
if (byte ^ crc) & 1:
crc = (crc >> 1) ^ value # poly
else:
crc >>= 1
byte >>= 1
crc16_table.append(crc)
for ch in string:
value = crc16_table[ord(ch) ^ (value & 0xff)] ^ (value >> 8)
return value
"
The text was updated successfully, but these errors were encountered:
Hi, I find crc16 algorithms has many other polynomials.
In helper.py, crc16 function is:
"
def crc16(string, value=0):
"""
CRC-16 poly: p(x) = x16 + x15 + x**2 + 1
"""
crc16_table = []
for byte in range(256):
crc = 0
"
and I am not sure the funtion can be writen like this:
"
def crc16(string, value=0xa001):
"""
CRC-16 poly: p(x) = x16 + x15 + x**2 + 1
@:param value:
CRC-16 model
P_16 0xa001
P_CCITT 0x1021
P-DNP 0xa6bc
p_KERMIT 0x8408
P_SICK 0x8005
"""
crc16_table = []
for byte in range(256):
crc = 0
"
The text was updated successfully, but these errors were encountered: