moneroBase58Encode function

String moneroBase58Encode(
  1. Uint8List data
)

Monero's block-based base58: input split into 8-byte blocks, each independently encoded to a fixed number of base58 chars.

Implementation

String moneroBase58Encode(Uint8List data) {
  if (data.isEmpty) return '';

  final buf = StringBuffer();
  final fullBlocks = data.length ~/ _fullBlockSize;
  final remainder = data.length % _fullBlockSize;

  for (var i = 0; i < fullBlocks; i++) {
    final start = i * _fullBlockSize;
    buf.write(_encodeBlock(
        Uint8List.sublistView(data, start, start + _fullBlockSize)));
  }

  if (remainder > 0) {
    final start = fullBlocks * _fullBlockSize;
    buf.write(
        _encodeBlock(Uint8List.sublistView(data, start, start + remainder)));
  }

  return buf.toString();
}