crc32Add function

Uint8List crc32Add(
  1. Uint8List buf
)

Prepend a big-endian CRC32 checksum. @param {Buffer} buf @returns {Buffer}

Implementation

Uint8List crc32Add(Uint8List buf) {
  final view = ByteData(4);
  view.setUint32(0, getCrc32(buf.buffer));
  final checksum = view.buffer.asUint8List();
  final bytes = Uint8List.fromList(buf);
  return Uint8List.fromList([...checksum, ...bytes]);
}