encode static method
Encode the provided BytesData of dataBytes into a Monero Base58 encoded string.
Implementation
static String encode(List<int> dataBytes) {
dataBytes = dataBytes.asImmutableBytes;
String enc = '';
/// Get lengths
final dataLen = dataBytes.length;
const blockDecLen = Base58XmrConst.blockDecMaxByteLen;
/// Compute total block count and last block length
final totBlockCnt = dataLen ~/ blockDecLen;
final lastBlockEncLen = dataLen % blockDecLen;
/// Encode each single block and pad
for (var i = 0; i < totBlockCnt; i++) {
final blockEnc = Base58Encoder.encode(
dataBytes.sublist(i * blockDecLen, (i + 1) * blockDecLen));
enc += _pad(blockEnc, Base58XmrConst.blockEncMaxByteLen);
}
/// Encode last block and pad
if (lastBlockEncLen > 0) {
final blockEnc = Base58Encoder.encode(dataBytes.sublist(
totBlockCnt * blockDecLen,
totBlockCnt * blockDecLen + lastBlockEncLen));
enc += _pad(blockEnc, Base58XmrConst.blockEncByteLens[lastBlockEncLen]);
}
return enc;
}