convert method
Converts input
and returns the result of the conversion.
Implementation
@override
String convert(Bech32 input) {
String hrp = input.hrp;
final data = input.data;
if (hrp.length +
data.length +
_separator.length +
Bech32ValidationsMixin.checksumLength >
Bech32ValidationsMixin.maxInputLength) {
throw TooLong(
hrp.length + data.length + 1 + Bech32ValidationsMixin.checksumLength,
);
}
if (hrp.isEmpty) {
throw const TooShortHrp();
}
if (hasOutOfRangeHrpCharacters(hrp)) {
throw OutOfRangeHrpCharacters(hrp);
}
if (isMixedCase(hrp)) {
throw MixedCase(hrp);
}
hrp = hrp.toLowerCase();
final checksum = data + _createChecksum(hrp, data);
if (hasOutOfBoundsChars(checksum)) {
throw const OutOfBoundChars('<unknown>');
}
return hrp + _separator + checksum.map((i) => charset[i]).join();
}