getCrc32 function Null safety
Get the CRC-32 checksum of the given array. You can append bytes to an
already computed crc by specifying the previous crc
value.
Implementation
int getCrc32(List<int> array, [int crc = 0]) {
var len = array.length;
crc = crc ^ 0xffffffff;
var ip = 0;
while (len >= 8) {
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
len -= 8;
}
if (len > 0) {
do {
crc = _crc32Table[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
} while (--len > 0);
}
return crc ^ 0xffffffff;
}