decodeBech32 method

  1. @override
List<String> decodeBech32(
  1. String bech32String
)
override

Decodes a bech32 string into a hex string and a hrp human readable part.

final decodedHexString = Nostr.instance.keysService.decodeBech32(npubString);
print(decodedHexString); // ...

Implementation

@override
List<String> decodeBech32(String bech32String) {
  final Bech32Codec codec = const Bech32Codec();
  final Bech32 bech32 = codec.decode(bech32String, bech32String.length);
  final eightBitWords = _convertBits(bech32.data, 5, 8, false);
  return [HEX.encode(eightBitWords), bech32.hrp];
}