Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blake2s

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blake2s - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

blake2s.ts

@@ -1326,3 +1326,3 @@ class BLAKE2s {

}
this.nx = length;
this.nx += length;
}

@@ -1329,0 +1329,0 @@

@@ -1285,3 +1285,3 @@ var Buffer = require('buffer').Buffer

}
this.nx = length;
this.nx += length;
};

@@ -1288,0 +1288,0 @@

{
"name": "blake2s",
"description": "port of Dmitry Chestnykh's blake2s-js to node style",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/dominictarr/blake2s",

@@ -6,0 +6,0 @@ "repository": {

@@ -18,12 +18,15 @@ # BLAKE2s

var h = new BLAKE2s(32); // constructor accepts digest length in bytes
h.update("string or array of bytes");
h.hexDigest(); // returns string with hex digest
h.digest(); // returns array of bytes
``` js
// constructor accepts digest length in bytes
var h = new BLAKE2s(32)
//pass encoding into update, like in node's crypto module
h.update("string or array of bytes", 'utf8')
//request the digest encoding
h.digest('hex')
// Keyed:
var h = new BLAKE2s(32, "some key");
...
// Keyed:
var h = new BLAKE2s(32, "some key")
...
```
## Demo

@@ -30,0 +33,0 @@

@@ -564,2 +564,26 @@ // Run: node test.js

// short inputs
console.log("Testing short inputs...");
for (i = 2; i < 128; i++) {
var arr = [];
for (j = 0; j < i; j++) arr.push(j);
var h0 = new BLAKE2s(32);
h0.update(arr);
var good = h0.digest('hex');
var h1 = new BLAKE2s(32);
h1.update(new Buffer(arr).slice(0, Math.floor(i/2)));
h1.update(new Buffer(arr).slice(Math.floor(i/2), arr.length));
var cand = h1.digest('hex');
if (good != cand) {
console.log('fail #', i, '\n', 'have', cand, '\n', 'need', good);
fails++;
} else {
passes++;
}
}
if (fails == 0) {

@@ -570,1 +594,33 @@ console.log('PASS');

}
// Benchmark.
(function() {
var i;
var buf = [];
for (i = 0; i < 1024; i++) {
buf.push(i & 0xff);
}
var h = new BLAKE2s(32);
var startTime = new Date();
for (i = 0; i < 1024; i++) {
h.update(buf);
}
var duration = (new Date()) - startTime;
console.log('BLAKE2s\t', duration + ' ms\t|\t', 1/(duration/1000) + ' MB/s');
})();
(function() {
var crypto = require('crypto');
var i;
var buf = new Buffer(1024);
for (i = 0; i < 1024; i++) {
buf[i] = (i & 0xff);
}
var h = crypto.createHash('sha1');
var startTime = new Date();
for (i = 0; i < 1024; i++) {
h.update(buf);
}
var duration = (new Date()) - startTime;
console.log('SHA-1\t', duration + ' ms\t|\t', 1/(duration/1000) + ' MB/s');
})();
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