function toBech32(data, version, prefix) {
  const words = bech32.toWords(data);
  words.unshift(version);
  return version === 0
    ? bech32.encode(prefix, words)
    : bech32m.encode(prefix, words);
}
Converts a buffer to a Bech32 or Bech32m encoded string.
@param data - The buffer to be encoded.
@param version - The version number to be used in the encoding.
@param prefix - The prefix string to be used in the encoding.
@returns The Bech32 or Bech32m encoded string.