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

blake2b-no-wasm

v2.1.4

Published

Blake2b (64-bit version) in pure Javascript

Downloads

1,117

Readme

blake2b

Build Status

Blake2b (64-bit version) in pure Javascript

This module is based on @dcposch implementation of BLAKE2b, with some changes:

  • This module requires you to pass in a out buffer, saving an allocation
  • This module allows you to set the salt and personal parameters
  • This module exports constants for the parameters in libsodium style

All credit goes to @dcposch for doing the hard work of porting the implementation from C to Javascript.

Usage

var blake2b = require("blake2b");

var output = new Uint8Array(64);
var input = Buffer.from("hello world");

console.log("hash:", blake2b(output.length).update(input).digest("hex"));

API

var hash = blake2b(outLength, [key], [salt], [personal], [noAssert = false])

Create a new hash instance, optionally with key, salt and personal. Bypass input assertions by setting noAssert to true.

All parameters must be Uint8Array, Buffer or another object with a compatible API. All parameters must also fulfill the following constraints, or an AssertionError will be thrown (unless noAssert = true):

  • outLength must within the byte ranges defined by the constants below.
  • key is optional, but must within the byte ranges defined by the constants below, if given. This value must be kept secret, and can be used to create prefix-MACs.
  • salt is optional, but must be exactly SALTBYTES, if given. You can use this parameter as a kind of per user id, or local versioning scheme. This value is not required to be secret.
  • personal is optional, but must be exactly PERSONALBYTES, if given. You can use this parameter as a kind of app id, or global versioning scheme. This value is not required to be secret.

var hash = hash.update(input)

Update the hash with new input. Calling this method after .digest will throw an error.

var out = hash.digest(out)

Finalise the the hash and write the digest to out. out must be exactly equal to outLength given in the blake2b method.

Optionally you can pass hex to get the hash as a hex string or no arguments to have the hash return a new Uint8Array with the hash.

Constants

  • blake2b.BYTES_MIN Minimum length of out
  • blake2b.BYTES_MAX Maximum length of out
  • blake2b.BYTES Recommended default length of out
  • blake2b.KEYBYTES_MIN Minimum length of key
  • blake2b.KEYBYTES_MAX Maximum length of key
  • blake2b.KEYBYTES Recommended default length of key
  • blake2b.SALTBYTES Required length of salt
  • blake2b.PERSONALBYTES Required length of personal

Install

npm install blake2b

Test vectors

This repository includes test vectors with {outlen, out, input, key, salt, personal} objects for testing conformance against the spec and other implementations:

License

ISC