encodeCheck function

String encodeCheck(
  1. Uint8List bytes, {
  2. String alphabet = bs58.bitcoin,
})

Encode data and add checksum for error detection (used in Bitcoin).

Implementation

String encodeCheck(Uint8List bytes, {String alphabet = bs58.bitcoin}) {
  Uint8List hash = doubleHash(bytes);
  Uint8List combine = Uint8List.fromList(
      [bytes, hash.sublist(0, 4)].expand((i) => i).toList(growable: false));
  return bs58.encode(combine, alphabet: alphabet);
}