encode method

List<int> encode(
  1. List<int> data,
  2. int eccCount
)

Implementation

List<int> encode(List<int> data, int eccCount) {
  final generator = getPolynomial(eccCount);
  var info = GFPoly(gf, data);
  info = info.multByMonominal(eccCount, 1);
  final remainder = info.divide(generator)[1];

  final result = List<int>.filled(eccCount, 0);
  final numZero = eccCount - remainder.coefficients.length;
  result.setAll(numZero, remainder.coefficients);
  return result;
}