generateECBytes static method

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

Implementation

static Uint8List generateECBytes(Uint8List dataBytes, int numEcBytesInBlock) {
  final numDataBytes = dataBytes.length;
  final toEncode = <int>[];
  for (int i = 0; i < numDataBytes; i++) {
    toEncode.add(dataBytes[i]);
  }
  toEncode.addAll(List.filled(numEcBytesInBlock, 0));
  ReedSolomonEncoder(GenericGF.qrCodeField256)
      .encode(toEncode, numEcBytesInBlock);

  final ecBytes = Uint8List(numEcBytesInBlock);
  for (int i = 0; i < numEcBytesInBlock; i++) {
    ecBytes[i] = toEncode[numDataBytes + i];
  }
  return ecBytes;
}