encode static method
Encodes dataBytes the way Monero encodes addresses and keys.
Implementation
static String encode(List<int> dataBytes) {
dataBytes = dataBytes.asImmutableBytes;
const blockSize = Base58XmrConst.blockDecMaxByteLen;
final fullBlockCount = dataBytes.length ~/ blockSize;
final finalBlockLen = dataBytes.length % blockSize;
final out = StringBuffer();
for (var i = 0; i < fullBlockCount; i++) {
final block = dataBytes.sublist(i * blockSize, (i + 1) * blockSize);
out.write(
_padLeft(
Base58Encoder.encode(block),
Base58XmrConst.blockEncMaxByteLen,
),
);
}
if (finalBlockLen > 0) {
final block = dataBytes.sublist(
fullBlockCount * blockSize,
dataBytes.length,
);
final targetLen = Base58XmrConst.blockEncByteLens[finalBlockLen];
out.write(_padLeft(Base58Encoder.encode(block), targetLen));
}
return out.toString();
}