checkSumModulo10 method

String checkSumModulo10(
  1. String data
)

Calculate the Checksum using a modulo 10

Implementation

String checkSumModulo10(String data) {
  var sum = 0;
  var fak = data.length;
  for (var c in data.codeUnits) {
    if (fak % 2 == 0) {
      sum += c - 0x30;
    } else {
      sum += (c - 0x30) * 3;
    }
    fak--;
  }
  if (sum % 10 == 0) {
    return '0';
  } else {
    return String.fromCharCode(10 - (sum % 10) + 0x30);
  }
}