Socket
Socket
Sign inDemoInstall

blakejs

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blakejs - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

2

package.json
{
"name": "blakejs",
"version": "1.0.1",
"version": "1.1.0",
"description": "Pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,13 +7,17 @@ BLAKE.js

**This is a pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions.**
**blake.js is a pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions.**
BLAKE is the default family of hash functions in the venerable NaCl crypto library. Like SHA2 and SHA3 but unlike MD5 and SHA1, BLAKE offers solid security. With an optimized assembly implementation, BLAKE can be faster than all of those other hash functions.
![blake1](https://cloud.githubusercontent.com/assets/169280/25921238/9bf1877a-3589-11e7-8a93-74b69c3874bb.jpg)
---
[RFC 7693: The BLAKE Cryptographic Hash and MAC](https://tools.ietf.org/html/rfc7693)
BLAKE is the default family of hash functions in the venerable NaCl crypto library. Like SHA2 and SHA3 but unlike MD5 and SHA1, BLAKE offers solid security. With an optimized assembly implementation, BLAKE can be faster than all of those other hash functions.
Of course, this implementation is in Javascript, so it won't be winning any speed records. More under Performance below. It's short and sweet, less than 500 LOC.
**As far as I know, it's the only package available today to compute BLAKE2s and BLAKE2b in a browser.**
**As far as I know, this is the only package available today to compute BLAKE in a browser.**
Example
Quick Start
---

@@ -30,4 +34,5 @@ ```js

---
**First, `blake2b` computes a BLAKE2b hash.**
### 1. Use `blake2b` to compute a BLAKE2b hash
Pass it a string, `Buffer`, or `Uint8Array` containing bytes to hash, and it will return a `Uint8Array` containing the hash.

@@ -52,3 +57,3 @@

**Second, you can use `blake2bInit`, `blake2bUpdate`, and `blake2bFinall` to compute the hash of a stream of bytes.**
### 2. Use `blake2b[Init,Update,Final]` to compute a streaming hash

@@ -68,4 +73,8 @@ ```js

**Finally, all five of these functions (`blake2b`, `blake2bHex`, `blake2bInit`, `blake2bUpdate`, and `blake2bFinal`) have `blake2s` equivalents.**
### 3. All `blake2b*` functions have `blake2s*` equivalents
BLAKE2b: `blake2b`, `blake2bHex`, `blake2bInit`, `blake2bUpdate`, and `blake2bFinal`
BLAKE2s: `blake2s`, `blake2sHex`, `blake2sInit`, `blake2sUpdate`, and `blake2sFinal`
The inputs are identical except that maximum key size and maximum output size are 32 bytes instead of 64.

@@ -72,0 +81,0 @@

@@ -29,3 +29,3 @@ var test = require('tape')

t.equal(blake2bHex(new Uint8Array([97, 98, 99])), blake2bHex('abc'))
t.equal(blake2bHex(new Buffer([97, 98, 99])), blake2bHex('abc'))
t.equal(blake2bHex(Buffer.from([97, 98, 99])), blake2bHex('abc'))
t.end()

@@ -32,0 +32,0 @@ })

@@ -17,3 +17,3 @@ var test = require('tape')

'508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982')
t.equal(blake2sHex(new Buffer([97, 98, 99])),
t.equal(blake2sHex(Buffer.from([97, 98, 99])),
'508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982')

@@ -20,0 +20,0 @@ t.end()

@@ -11,3 +11,3 @@ var ERROR_MSG_INPUT = 'Input must be an string, Buffer or Uint8Array'

} else if (typeof (input) === 'string') {
ret = new Uint8Array(new Buffer(input, 'utf8'))
ret = new Uint8Array(Buffer.from(input, 'utf8'))
} else {

@@ -14,0 +14,0 @@ throw new Error(ERROR_MSG_INPUT)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc