getCrc32 function

int getCrc32(
  1. ByteBuffer buf
)

Calculate the CRC32 of a blob. @param buf The blob to calculate the CRC32 of.

Implementation

int getCrc32(ByteBuffer buf) {
  var b = buf.asUint8List();
  var crc = -1;

  // tslint:disable-next-line:prefer-for-of
  for (var i = 0; i < b.length; i++) {
    var byte = b[i];
    var t = (byte ^ crc) & 0xff;
    crc = lookUpTable[t] ^ ((crc & 0xffffffff) >> 8);
  }

  return ((crc ^ -1) & 0xffffffff) >> 0;
}