All Projects → vrza → node-blake2

vrza / node-blake2

Licence: other
All four BLAKE2 variants (blake2b, blake2bp, blake2s, blake2sp) with stream support for Node.js

Programming Languages

c
50402 projects - #5 most used programming language
C#
18002 projects
javascript
184084 projects - #8 most used programming language
C++
36643 projects - #6 most used programming language
Makefile
30231 projects
Roff
2310 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to node-blake2

noble-hashes
Audited & minimal JS implementation of SHA2, SHA3, RIPEMD, BLAKE2/3, HMAC, HKDF, PBKDF2 & Scrypt
Stars: ✭ 213 (+309.62%)
Mutual labels:  hashing, hash, blake2
Ahash
aHash is a non-cryptographic hashing algorithm that uses the AES hardware instruction
Stars: ✭ 251 (+382.69%)
Mutual labels:  hashing, hash
agent-python
Official python agent for using the distributed hashcracker Hashtopolis
Stars: ✭ 39 (-25%)
Mutual labels:  hashing, hash
Eternal
A C++14 compile-time/constexpr map and hash map with minimal binary footprint
Stars: ✭ 93 (+78.85%)
Mutual labels:  hashing, hash
laravel-hashid
HashId Implementation on Laravel Eloquent ORM
Stars: ✭ 23 (-55.77%)
Mutual labels:  hashing, hash
pthash
Fast and compact minimal perfect hash functions in C++.
Stars: ✭ 62 (+19.23%)
Mutual labels:  hashing, hash
Wyhash Rs
wyhash fast portable non-cryptographic hashing algorithm and random number generator in Rust
Stars: ✭ 44 (-15.38%)
Mutual labels:  hashing, hash
haiti
🔑 Hash type identifier (CLI & lib)
Stars: ✭ 287 (+451.92%)
Mutual labels:  hashing, hash
Minperf
A Minimal Perfect Hash Function Library
Stars: ✭ 107 (+105.77%)
Mutual labels:  hashing, hash
Data Structures
Data-Structures using C++.
Stars: ✭ 121 (+132.69%)
Mutual labels:  hashing, hash
Password4j
Password4j is a user-friendly cryptographic library that supports Argon2, Bcrypt, Scrypt, PBKDF2 and various cryptographic hash functions.
Stars: ✭ 124 (+138.46%)
Mutual labels:  hashing, hash
bromberg sl2
Cayley hashing as in "Navigating in the Cayley Graph of SL₂(𝔽ₚ)"
Stars: ✭ 32 (-38.46%)
Mutual labels:  hashing, hash
agent
hashtopolis.org
Stars: ✭ 19 (-63.46%)
Mutual labels:  hashing, hash
komihash
Very fast, high-quality hash function (non-cryptographic, C) + PRNG
Stars: ✭ 68 (+30.77%)
Mutual labels:  hashing, hash
metrohash-rs
Rust MetroHash
Stars: ✭ 45 (-13.46%)
Mutual labels:  hashing, hash
Name That Hash
🔗 Don't know what type of hash it is? Name That Hash will name that hash type! 🤖 Identify MD5, SHA256 and 3000+ other hashes ☄ Comes with a neat web app 🔥
Stars: ✭ 540 (+938.46%)
Mutual labels:  hashing, hash
Util
A collection of useful utility functions
Stars: ✭ 201 (+286.54%)
Mutual labels:  hashing, hash
hash-checker
Fast and simple application that allows you to generate and compare hashes from files and text
Stars: ✭ 72 (+38.46%)
Mutual labels:  hashing, hash
Xxhash cpp
Port of the xxhash library to C++17.
Stars: ✭ 106 (+103.85%)
Mutual labels:  hashing, hash
Dagon
Advanced Hash Manipulation
Stars: ✭ 155 (+198.08%)
Mutual labels:  hashing, hash

node-blake2

NPM version Build status

Why BLAKE2 for hashing? "BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and SHA-3, yet is at least as secure as the latest standard SHA-3. BLAKE2 has been adopted by many projects due to its high speed, security, and simplicity." https://blake2.net/

node-blake2 provides a stream-compatible blake2b, blake2bp, blake2s, and blake2sp Hash and KeyedHash for Node.js.

node-blake2 has been tested to work with the following compilers and platforms:

Compiler Operating System Architecture
GCC 8.3.0 10.2.0, 11.2.0 GNU/Linux Gentoo x86_64
LLVM clang 11.1.0, 13.0.0 GNU/Linux Gentoo x86_64
GCC 5.4.0 GNU/Linux Ubuntu 16.04 x86_64
LLVM clang 11.1.0 OpenBSD 7.0 x86_64
Apple LLVM clang 9.1.0 macOS 10.13 x86_64
Visual Studio 2019 Windows 11 x86_64
Visual Studio 2015 Windows 10 x86_64
GCC 10.2.1 GNU/Linux RPi OS 2021-10-30 armv7l Cortex-A53 RPi 3
GCC 10.2.1 GNU/Linux Debian 11.2 aarch64 Cortex-A57 QEMU
GCC 9.3.0 GNU/Linux Ubuntu 20.04 aarch64 Cortex-A72 RPi 4
Apple LLVM clang 12.0.5 macOS 12 aarch64 Apple M1

Prerequisites for building on Windows

Visual Studio Build Tools.

Python is required by node-gyp.

Starting with Node.js 12, Windows installer can automatically install Python and Visual Studio build tools.

Install

In your project, run:

npm install blake2 --save

or install from the GitHub repo:

npm install vrza/node-blake2 --save

Examples

Unkeyed BLAKE2b

var blake2 = require('blake2');
var h = blake2.createHash('blake2b');
h.update(Buffer.from("test"));
console.log(h.digest("hex"));

blake2.createHash works like node's crypto.createHash.

Keyed BLAKE2b

var blake2 = require('blake2');
var h = blake2.createKeyedHash('blake2b', Buffer.from('key - up to 64 bytes for blake2b, 32 for blake2s'));
h.update(Buffer.from("test"));
console.log(h.digest("hex"));

blake2.createKeyedHash takes a key argument like crypto.createHmac. Although it is not an HMAC, a keyed hash serves the same purpose.

Important notes

  • blake2.create{Hash,KeyedHash} support algorithms blake2b, blake2bp, blake2s, and blake2sp.
  • Data passed to .update on blake2.{Hash,KeyedHash} must be a Buffer.
  • Keys passed to blake2.createKeyedHash(algo, key) must be a Buffer.
  • Just as with crypto.Hash, .digest() can only be called once.

With streams

This works exactly like it does with crypto.Hash. See b2sum.js.

Custom digest length

BLAKE2 can generate digests between 1-64 bytes for BLAKE2b and 1-32 bytes for BLAKE2s. Pass digestLength as an option to use a digest shorter than the default (maximum length):

var blake2 = require('blake2');
var h = blake2.createHash('blake2b', {digestLength: 16});
h.update(Buffer.from("test"));
h.digest(); // Returns a Buffer with 16 bytes

or with a key:

var blake2 = require('blake2');
var h = blake2.createKeyedHash('blake2b', Buffer.from('my key'), {digestLength: 16});
h.update(Buffer.from("test"));
h.digest(); // Returns a Buffer with 16 bytes

Note that BLAKE2 will generate completely different digests for shorter digest lengths; they are not simply a slice of the default digest.

Copying a hash object

You can call .copy() on a Hash or KeyedHash, which will return a new object with all of the internal BLAKE2 state copied from the source object.

var blake2 = require('blake2');
var h = blake2.createHash('blake2b');
h.update(Buffer.from("test"));

// Call .copy() before .digest(), because .digest() finalizes internal state
var j = h.copy();

// h is unaffected by updates to j
j.update(Buffer.from("more"));

console.log(h.digest());
console.log(j.digest());

Known issues

  • On Windows, node-blake2 requires enabling AVX instructions as a workaround for the way upstream build preprocessor detects support for SSE2.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].