MCPcopy Create free account
hub / github.com/geekcomputers/Python / crc_check

Function crc_check

CRC/crc.py:1–25  ·  view source on GitHub ↗
(data, div)

Source from the content-addressed store, hash-verified

1def crc_check(data, div):
2 l = len(div)
3 ct = 0
4 data = [int(i) for i in data]
5 div = [int(i) for i in div]
6 zero = [0 for i in range(l)]
7 temp_data = [data[i] for i in range(l)]
8 result = []
9 for j in range(len(data) - len(div) + 1):
10 print("Temp_dividend", temp_data)
11 msb = temp_data[0]
12 if msb == 0:
13 result.append(0)
14 for i in range(l - 1, -1, -1):
15 temp_data[i] = temp_data[i] ^ zero[i]
16 else:
17 result.append(1)
18 for i in range(l - 1, -1, -1):
19 temp_data[i] = temp_data[i] ^ div[i]
20 temp_data.pop(0)
21 if l + j < len(data):
22 temp_data.append(data[l + j])
23 crc = temp_data
24 print("Quotient: ", result, "remainder", crc)
25 return crc
26
27
28# returning crc value

Callers 1

crc.pyFile · 0.85

Calls 2

appendMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected