libp2p-crypto
0.14.1

Intro

Installable via npm install --save libp2p-crypto, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save libp2p-crypto

You can then require() libp2p-crypto as normal:

const libp2PCrypto = require('libp2p-crypto')

In the Browser

Libp2p-crypto should work in any ES2015 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of libp2p-crypto, including index.js and index.min.js, are included in the /dist folder. Libp2p-crypto can also be found on unpkg.com under

id

Gets the ID of the key.

The key id is the base58 encoding of the SHA-256 multihash of its public key. The public key is a protobuf encoding containing a type and the DER encoding of the PKCS SubjectPublicKeyInfo.

Parameters

  1. callback: function (Error, id):  

Returns

export

Exports the key into a password protected PEM format

Parameters

  1. format: string?:  
    Defaults to 'pkcs-8'.
  2. password: string:  
    The password to read the encrypted PEM
  3. callback: function (Error, KeyInfo):  

Returns

id

Gets the ID of the key.

The key id is the base58 encoding of the SHA-256 multihash of its public key. The public key is a protobuf encoding containing a type and the DER encoding of the PKCS SubjectPublicKeyInfo.

Parameters

  1. callback: function (Error, id):  

Returns

Computes the Password-Based Key Derivation Function 2.

Parameters

  1. password: string:  
  2. salt: string:  
  3. iterations: number:  
  4. keySize: number:  
    (in bytes)
  5. hash: string:  
    The hash name ('sha1', 'sha2-512, ...)

Returns

string A new password