multiple hash functions
npm install @arve.knudsen/multihashing-async







> Use all the functions in multihash.
#### 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
+ Use in a browser with browserify, webpack or any other bundler
+ Use in a browser Using a script tag
- Gotchas
* Usage
* Examples
+ Multihash output
* API
* Maintainers
* Contribute
* License
``bash`
$ npm install --save multihashing-async
`js`
const multihashing = require('multihashing-async')
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.
`js`
const multihashing = require('multihashing-async')
Loading this module through a script tag will make the multihashing obj
available in the global namespace.
`html`
#### 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.
`js
const multihashing = require('multihashing-async')
const buf = Buffer.from('beep boop')
multihashing(buf, 'sha1', (err, multihash) => {
// by default calls back with a multihash.
})
// Use .digest(...) if you want only the hash digest (drops the prefix indicating the hash type).
multihashing.digest(buf, 'sha1', (err , digest) => {
// digest is the raw digest
})
// Use .createHash(...) for the raw hash functions`
const h = multihashing.createHash('sha1')
h(buf, (err, digest) => {
// digest is a buffer of the sha1 of buf
})
`js
> 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))
// =>
``
https://multiformats.github.io/js-multihashing-async/
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.
MIT © 2016 Protocol Labs Inc.