ipfs-peer-id

0.3.2 • Public • Published

ipfs-peer-id Node.js implementation

[ Build Status](https://travis-ci.org/diasdavid/node-ipfs-peer-id) Dependency Status js-standard-style

IPFS Peer Id implementation in Node.js

Description

A IPFS Peer Id is based on a sha256 has of the peer public key, using multihash

Usage

Installing

$ npm install ipfs-peer-id

Creating a new Id

var PeerId = require('ipfs-peer')

// Create a new Id
var id = new Id.create()

// Recreate an Id from Hex string
var id = new Id.createFromHexString(str)

// Recreate an Id from a Buffer
var id = new Id.createFromBytes(buf)

// Recreate an B58 String
var id = new Id.createFromB58String(str)

// Recreate from a Public Key
var id = new Id.createFromPubKey(pubKey)

// Recreate from a Private Key
var id = new Id.createFromPrivKey(privKey)

Exporting an Id

// Print friendly format
id.toPrint() // returns an object with id, privKey and pubKey in hex format

// Export to an hex string
id.toHexString()

// Export to Buffer
id.toBytes() (same as id.id)

// Export to a B58 string
id.toB58String()

Id format

id.pubKey   // Buffer containing the Public Key
id.privKey  // Buffer containing the Private Key
id.id       // Buffer containing the multihash

Readme

Keywords

Package Sidebar

Install

npm i ipfs-peer-id

Weekly Downloads

1

Version

0.3.2

License

MIT

Last publish

Collaborators

  • daviddias