This function get 256-byte (256x8) table for efficient processing.
(model CRCModel)
| 51 | |
| 52 | // This function get 256-byte (256x8) table for efficient processing. |
| 53 | func getTable(model CRCModel) []uint8 { |
| 54 | table := make([]uint8, 256) |
| 55 | for i := 0; i < 256; i++ { |
| 56 | crc := uint8(i) |
| 57 | for j := 0; j < 8; j++ { |
| 58 | isSetBit := (crc & 0x80) != 0 |
| 59 | crc <<= 1 |
| 60 | if isSetBit { |
| 61 | crc ^= model.Poly |
| 62 | } |
| 63 | } |
| 64 | table[i] = crc |
| 65 | } |
| 66 | return table |
| 67 | } |