encodeBech32 static method
Encodes data into a Bech32 string.
Parameters:
- hrp: The Human-Readable Part (prefix) of the Bech32 string.
- data: The data to be encoded as a List
- sep: The separator character used in the Bech32 string.
- computeChecksum: A function that computes the checksum for the Bech32 string.
Returns: A Bech32-encoded string representing the provided data with a checksum.
Implementation
static String encodeBech32(String hrp, List<int> data, String sep,
List<int> Function(String hrp, List<int> data) computeChecksum) {
final checksum = computeChecksum(hrp, data);
data = List<int>.from([...data, ...checksum]);
final encodedData =
hrp + sep + data.map((e) => Bech32BaseConst.charset[e]).join();
return encodedData;
}