do you know if there is a Python script? in Python Nostr there is a way to convert from hex to bec32 but not the other way around

Reply to this note

Please Login to reply.

Discussion

If you’re talking about a python library there is https://github.com/jeffthibault/python-nostr/tree/main/nostr

I checked the code and there is a bech32 encode and decode function.

I haven’t tried it or anything so it might be worth tinkering with.

Maybe someone can convert from one language to your language of choice for some sats.

ok I found the sequence:

From npub to hex

import bech32

npub = 'your npub'

hrp, data = bech32.bech32_decode(npub)

raw_public_key = bech32.convertbits(data, 5, 8)[:-1]

pubkey_hex = bytes(raw_public_key).hex()

print(pubkey_hex)