encode static method

String encode(
  1. String hrp,
  2. List<int> bytes, {
  3. Bech32Encodings encoding = Bech32Encodings.bech32,
})

Encodes data with a Human-Readable Part (HRP) into a Bech32 string.

This method takes an HRP and a byte array and encodes them into a Bech32 string using the standard Bech32 encoding.

  • hrp: The Human-Readable Part (prefix) of the Bech32 string.
  • bytes: The byte array to encode.

Returns the encoded Bech32 string.

Implementation

static String encode(
  String hrp,
  List<int> bytes, {
  Bech32Encodings encoding = Bech32Encodings.bech32,
}) {
  return Bech32EncoderBase.encodeBech32(
    hrp,
    Bech32BaseUtils.convertToBase32(bytes),
    Bech32Const.separator,
    (hrp, data) => Bech32Utils.computeChecksum(hrp, data, encoding),
  );
}