Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hypercore-id-encoding

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypercore-id-encoding

Convert Hypercore keys to/from z-base32 or hex

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

hypercore-id-encoding

Encodes Hypercore keys into z-base32 ids, and decodes both hex/z-base32 strings.

npm install hypercore-id-encoding

Usage

const { encode, decode } = require('hypercore-id-encoding')

const id = encode(core.key) // (z-base32 String)
const hexEncoded = core.key.toString('hex')

const core = new Hypercore(ram, decode(id)) 
const core2 = new Hypercore(ram, decode(hexEncoded)) // Will also work with hex

API

const id = encode(hypercoreKey)

Encodes a 32-byte Hypercore key into a z-base32 id.

hypercoreKey must be a Buffer or an ArrayBuffer.

const buf = decode(hypercoreId)

Decodes an id into a Hypercore key.

hypercoreId must be a String.

If hypercoreId is a 52-character String, it will be decoded as z-base32.

If hypercoreId is a 64-character String, it will be decoded as hex.

License

MIT

FAQs

Package last updated on 07 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc