calculateChecksum static method
Implementation
static Uint8List calculateChecksum(Uint8List bytes) {
fixNum.Int32 crc = fixNum.Int32(0x0000);
int count = bytes.length;
int i = 0;
fixNum.Int32 code;
while (count > 0) {
code = crc.shiftRightUnsigned(8) & 0xFF;
code ^= bytes[i++] & 0xFF;
code ^= code.shiftRightUnsigned(4);
crc = crc << 8 & 0xFFFF;
crc ^= code;
code = code << 5 & 0xFFFF;
crc ^= code;
code = code << 7 & 0xFFFF;
crc ^= code;
count--;
}
// little-endian
return Uint8List.fromList([crc.toInt(), crc.shiftRightUnsigned(8).toInt()]);
}