checkSumModulo10 method

String checkSumModulo10(
  1. String data
)

Implementation

String checkSumModulo10(String data) {
  int sum = 0;
  int fak = data.length;
  for (final int 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);
  }
}