Giter Club home page Giter Club logo

key-convertr's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.