js-multihashing-async
Use all the functions in multihash.
Lead Maintainer
Hugo Dias
Wait, why, how is this different from Node crypto
?
This module just makes working with multihashes a bit nicer.
js-multihash is only for
encoding/decoding multihashes, and does not depend on other libs.
This module will depend on various implementations for each hash.
It currently uses crypto
and sha3
in Node.js.
In the browser webcrypto
and browserify-sha3
are used.
Table of Contents
Install
In Node.js through npm
$ npm install --save multihashing-async
const multihashing = require('multihashing-async')
Use in a browser with browserify, webpack or any other bundler
The code published to npm that gets loaded on require is in fact a ES5 transpiled
version with the right shims added. This means that you can require it and use with
your favourite bundler without having to adjust asset management process.
const multihashing = require('multihashing-async')
Use in a browser Using a script tag
Loading this module through a script tag will make the multihashing
obj
available in the global namespace.
<script src="https://unpkg.com/multihashing-async/dist/index.min.js"></script>
<script src="https://unpkg.com/multihashing-async/dist/index.js"></script>
Gotchas
You will need to use Node.js Buffer
API compatible, if you are running inside the browser, you can access it by multihashing.Buffer
or you can install Feross's Buffer.
Usage
const multihashing = require('multihashing-async')
const buf = Buffer.from('beep boop')
multihashing(buf, 'sha1', (err, multihash) => {
})
multihashing.digest(buf, 'sha1', (err , digest) => {
})
const h = multihashing.createHash('sha1')
h(buf, (err, digest) => {
})
Examples
Multihash output
> const multihashing = require('multihashing-async')
> const buf = Buffer.from('beep boop')
> multihashing(buf, 'sha1', (err, mh) => console.log(mh))
> multihashing(buf, 'sha2-256', (err, mh) => console.log(mh))
> multihashing(buf, 'sha2-512', (err, mh) => console.log(mh))
API
https://multiformats.github.io/js-multihashing-async/
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 © 2016 Protocol Labs Inc.