+1
-1
@@ -1326,3 +1326,3 @@ class BLAKE2s { | ||
| } | ||
| this.nx = length; | ||
| this.nx += length; | ||
| } | ||
@@ -1329,0 +1329,0 @@ |
+1
-1
@@ -1285,3 +1285,3 @@ var Buffer = require('buffer').Buffer | ||
| } | ||
| this.nx = length; | ||
| this.nx += length; | ||
| }; | ||
@@ -1288,0 +1288,0 @@ |
+1
-1
| { | ||
| "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": { |
+11
-8
@@ -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 @@ |
+56
-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'); | ||
| })(); |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
109837
1.21%3253
1.53%45
7.14%