Skip to content

convert nostr keys and note-ids between hex and bech32

Notifications You must be signed in to change notification settings

peterschmidler/key-convertr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Key-Convertr

People are copy-pasting nostr private keys into webpages to convert between the original hex-encoding and bech32-encoding (specified in NIP-19).

This is kind of bonkers, so here's a command-line utility that you can run to convert public/private keys between hex-encoding and the NIP-19 bech32 encoding. IT can also convert note id's.

Installation

Building with Cargo

If you have cargo installed, then from the key-convertr directory, just do cargo install --path .. It will put a program called key-convertr in your $HOME/.cargo/bin directory.

Then, to convert from a hex-encoded pubkey to a bech32-encoded pubkey, you can do

$> key-convertr --kind npub 3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d
npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6

Running with Docker

If you have docker installed, you can simply do docker run --rm ghcr.io/rot13maxi/key-convertr:main to download and run the latest main revision of the tool. Then just follow the instructions below. For example,

$> docker run --rm ghcr.io/rot13maxi/key-convertr:main --kind npub 3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d
npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6

Building with Docker

If you have docker installed, you can do docker build -f docker/Dockerfile -t key-convertr . to build a container (no local cargo install required!). Then just do docker run --rm key-convertr [args] to run it. For example:

$> docker run --rm key-convertr --kind npub 3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d
npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6

Usage

Just provide the hex-encoded key or note-id and a --kind argument. The kinds supported are:

  • npub
  • nsec
  • note

To convert from an npub to hex-encoding, you can do

$> key-convertr --to-hex npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6
3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d

You can also pass multiple keys/notes to the tool by putting a comma or space between them. For example,

$> key-convertr --kind npub 3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d,863883611bdbe6291c081fb8775908a7ab0cb04b608405ec1e85e9f938020a98
npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6
npub1scugxcgmm0nzj8qgr7u8wkgg574sevztvzzqtmq7sh5ljwqzp2vqf45w5j

About

convert nostr keys and note-ids between hex and bech32

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 67.5%
  • Rust 28.5%
  • Dockerfile 4.0%