calculateCheckSum function

String calculateCheckSum(
  1. Uint8List address,
  2. Uint8List prefix
)

Implementation

String calculateCheckSum(Uint8List address, Uint8List prefix) {
  final concatenated =
      BytesBuilder()
        ..add(address)
        ..add(prefix);
  final hexedConcat = '${bytesToHex(concatenated.toBytes())}00'.toUpperCase();
  var mods = '';
  for (final rune in hexedConcat.runes) {
    if (rune > 64 && rune < 91) {
      mods += (rune - 55).toString();
    } else {
      mods += (rune - 48).toString();
    }
  }
  final result =
      (BigInt.from(98) - BigInt.parse(mods) % BigInt.from(97)).toInt();
  if (result < 10) {
    return '0$result';
  }
  return result.toString();
}