Options
All
  • Public
  • Public/Protected
  • All
Menu

multihashes - v4.0.2

js-multihash

codecov GitHub Workflow Status

multihash implementation in node.js

This is the multihash implementation in Node. It is extended by js-multihashing and js-multihashing-async, so give those a look as well.

Lead Maintainer

Hugo Dias

Table of Contents

Install

Using npm

> npm install multihashes # NOTE: The name of the module is multihashes!

Using a <script> tag

Loading this module through a script tag will make the Multihashes obj available in the global namespace.

<script src="https://unpkg.com/multihashes/dist/index.min.js"></script>

Usage

> var multihash = require('multihashes')
> var bytes = Uint8Array.from([0, 1, 2, 3...])

> var encoded = multihash.encode(bytes, 'sha1')
> console.log(encoded)
<Uint8Array 11 14 0b ee c7 b5 ea 3f 0f db c9 5d 0d d4 7f 3c 5b c2 75 da 8a 33>

> multihash.decode(encoded)
{ code: 17,
  name: 'sha1',
  length: 20,
  digest: <Uint8Array 0b ee c7 b5 ea 3f 0f db c9 5d 0d d4 7f 3c 5b c2 75 da 8a 33> }

API

https://multiformats.github.io/js-multihash/

Update Constants

To update the constants table run the command below. This will fetch the main codec list from https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv and filter only the multihash codecs and update the constants.js file in this repo.

npm run update-constants

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © Protocol Labs Inc.