generateECBytes static method

Int8List generateECBytes(
  1. Int8List dataBytes,
  2. int numEcBytesInBlock
)

Implementation

static Int8List generateECBytes(Int8List dataBytes, int numEcBytesInBlock) {
  var numDataBytes = dataBytes.length;
  var toEncode = Int32List(numDataBytes + numEcBytesInBlock);
  for (var i = 0; i < numDataBytes; i++) {
    toEncode[i] = dataBytes[i] & 0xFF;
  }
  ReedSolomonEncoder(GenericGF.qrCodeField256)
      .encode(toEncode, numEcBytesInBlock);

  var ecBytes = Int8List(numEcBytesInBlock);
  for (var i = 0; i < numEcBytesInBlock; i++) {
    ecBytes[i] = toEncode[numDataBytes + i];
  }
  return ecBytes;
}