I have tried for over 3 hours to make a code that decrypts a ncryptsec with python and the nostr_sdk library but I cannot figure it out... I read the nip49 but I am not experienced enough to make it work...

Does anyone know how to do it or have an example for python?

nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gprfmhxue69uhkcmmrdd3x77pwve5kzar2v9nzucm0d5hszxmhwden5te0wfjkccte9emk2um5v4exucn5vvhxxmmd9ux73xm6 #asknostr

Reply to this note

Please Login to reply.

Discussion

You could have learned another language in those 3 hours instead.

Sorry, I don't have an example in Python. If I were to try I think it would take more than 3 hours.

I did it!! 🚀

Ouf yeah I had to understand the library in order to write the commands in the right way...

Which language do you recommend to get into for building on Nostr?

+1

Go

I had this posted a while ago

was using nostr_sdk 0.32 at that time

but feels like the code is not working anymore with 0.39 (latest nostr_sdk version)

https://alashazam.wordpress.com/2024/07/07/python-nostr_sdk-fetching-all-metadata/

crashes with error:

AttributeError: type object 'PublicKey' has no attribute 'from_bech32'. Did you mean: 'to_bech32'?

Yeah it should be to_bech32. Here is an example code from their GitHub https://github.com/rust-nostr/nostr/blob/master/bindings/nostr-sdk-ffi/python/examples/metadata.py

good find, but that program is a bit too old as well, (it is only one month old) ... but it crashes with this error :

nostr:nevent1qgs2xyfsr74phxjwj6tqrp8wgshhp3ktkuuqgnkfvwk59lexge3l3usqyqzy3slfqlxr3u5sncrqm5lc2kx5x6lf7jhgr3wvxnv2cr8s7z6l2vsdn6n

```python

from nostr_sdk import EncryptedSecretKey

encrypted = EncryptedSecretKey.from_bech32("ncryptsec...")

secret_key = encrypted.to_secret_key("")

```