| 1 | def 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 |