npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zippie/multihashing-async-mini

v0.8.1

Published

same api, just one hash function

Downloads

1

Readme

js-multihashing-async

Coverage Status Travis CI Dependency Status js-standard-style

Use all the functions in multihash.

Lead Maintainer

Hugo Dias

Notice

This module is moving to async/await starting from 0.7.0.
The last minor version to support callbacks is 0.6.0, any backports will merged to the branch callbacks and released under >0.6.0 <0.7.0.

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>
<!-- OR -->
<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')

const mh = await multihashing(buf, 'sha1')

// Use `.digest(...)` if you want only the hash digest (drops the prefix indicating the hash type).
const digest = await multihashing.digest(buf, 'sha1')

// Use `.createHash(...)` for the raw hash functions
const hash = multihashing.createHash('sha1')
const digest = await hash(buf)

Examples

Multihash output

const multihashing = require('multihashing-async')
const buf = Buffer.from('beep boop')

const mh = await multihashing(buf, 'sha1')
console.log(mh)
// => <Buffer 11 14 7c 83 57 57 7f 51 d4 f0 a8 d3 93 aa 1a aa fb 28 86 3d 94 21>

const mh = await multihashing(buf, 'sha2-256')
console.log(mh)
// => <Buffer 12 20 90 ea 68 8e 27 5d 58 05 67 32 50 32 49 2b 59 7b c7 72 21 c6 24 93 e7 63 30 b8 5d dd a1 91 ef 7c>

const mh = await multihashing(buf, 'sha2-512')
console.log(mh)
// => <Buffer 13 40 14 f3 01 f3 1b e2 43 f3 4c 56 68 93 78 83 77 1f a3 81 00 2f 1a aa 5f 31 b3 f7 8e 50 0b 66 ff 2f 4f 8e a5 e3 c9 f5 a6 1b d0 73 e2 45 2c 48 04 84 b0 ...>

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 © Protocol Labs Inc.