Comparing version 2.1.3 to 2.1.4
22
index.js
@@ -214,3 +214,3 @@ var assert = require('nanoassert') | ||
Blake2b.prototype.update = function (input) { | ||
assert(input != null, 'input must be Uint8Array or Buffer') | ||
assert(input instanceof Uint8Array, 'input must be Uint8Array or Buffer') | ||
blake2bUpdate(this, input) | ||
@@ -222,2 +222,3 @@ return this | ||
var buf = (!out || out === 'binary' || out === 'hex') ? new Uint8Array(this.outlen) : out | ||
assert(buf instanceof Uint8Array, 'out must be "binary", "hex", Uint8Array, or Buffer') | ||
assert(buf.length >= this.outlen, 'out must have at least outlen bytes of space') | ||
@@ -283,6 +284,15 @@ blake2bFinal(this, buf) | ||
assert(outlen <= BYTES_MAX, 'outlen must be at most ' + BYTES_MAX + ', was given ' + outlen) | ||
if (key != null) assert(key.length >= KEYBYTES_MIN, 'key must be at least ' + KEYBYTES_MIN + ', was given ' + key.length) | ||
if (key != null) assert(key.length <= KEYBYTES_MAX, 'key must be at most ' + KEYBYTES_MAX + ', was given ' + key.length) | ||
if (salt != null) assert(salt.length === SALTBYTES, 'salt must be exactly ' + SALTBYTES + ', was given ' + salt.length) | ||
if (personal != null) assert(personal.length === PERSONALBYTES, 'personal must be exactly ' + PERSONALBYTES + ', was given ' + personal.length) | ||
if (key != null) { | ||
assert(key instanceof Uint8Array, 'key must be Uint8Array or Buffer') | ||
assert(key.length >= KEYBYTES_MIN, 'key must be at least ' + KEYBYTES_MIN + ', was given ' + key.length) | ||
assert(key.length <= KEYBYTES_MAX, 'key must be at most ' + KEYBYTES_MAX + ', was given ' + key.length) | ||
} | ||
if (salt != null) { | ||
assert(salt instanceof Uint8Array, 'salt must be Uint8Array or Buffer') | ||
assert(salt.length === SALTBYTES, 'salt must be exactly ' + SALTBYTES + ', was given ' + salt.length) | ||
} | ||
if (personal != null) { | ||
assert(personal instanceof Uint8Array, 'personal must be Uint8Array or Buffer') | ||
assert(personal.length === PERSONALBYTES, 'personal must be exactly ' + PERSONALBYTES + ', was given ' + personal.length) | ||
} | ||
} | ||
@@ -314,4 +324,4 @@ | ||
module.exports.WASM_LOADED = true | ||
Proto = b2wasm | ||
module.exports = b2wasm | ||
} | ||
}) |
{ | ||
"name": "blake2b", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Blake2b (64-bit version) in pure Javascript", | ||
"main": "index.js", | ||
"dependencies": { | ||
"blake2b-wasm": "^1.1.0", | ||
"nanoassert": "^1.0.0" | ||
"blake2b-wasm": "^2.4.0", | ||
"nanoassert": "^2.0.0" | ||
}, | ||
@@ -10,0 +10,0 @@ "devDependencies": { |
@@ -26,3 +26,3 @@ # `blake2b` | ||
blake2b(output, input) | ||
console.log('hash:', blake2b(output.length).update(input).digest('hex')) | ||
``` | ||
@@ -29,0 +29,0 @@ |
@@ -48,3 +48,3 @@ var test = require('tape') | ||
var isntance = blake2b(blake2b.BYTES) | ||
var buf = new Buffer('Hej, Verden') | ||
var buf = Buffer.from('Hej, Verden') | ||
@@ -65,3 +65,3 @@ for (var i = 0; i < 10; i++) isntance.update(buf) | ||
var instance = blake2b(blake2b.BYTES, key) | ||
var buf = new Buffer('Hej, Verden') | ||
var buf = Buffer.from('Hej, Verden') | ||
@@ -79,3 +79,3 @@ for (var i = 0; i < 10; i++) instance.update(buf) | ||
var isntance = blake2b(blake2b.BYTES_MIN) | ||
var buf = new Buffer('Hej, Verden') | ||
var buf = Buffer.from('Hej, Verden') | ||
@@ -96,3 +96,3 @@ for (var i = 0; i < 10; i++) isntance.update(buf) | ||
var instance = blake2b(blake2b.BYTES_MIN, key) | ||
var buf = new Buffer('Hej, Verden') | ||
var buf = Buffer.from('Hej, Verden') | ||
@@ -99,0 +99,0 @@ for (var i = 0; i < 10; i++) instance.update(buf) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
305440
1766
+ Addedb4a@1.6.7(transitive)
+ Addedblake2b-wasm@2.4.0(transitive)
+ Addednanoassert@2.0.0(transitive)
- Removedblake2b-wasm@1.1.7(transitive)
- Removednanoassert@1.1.0(transitive)
Updatedblake2b-wasm@^2.4.0
Updatednanoassert@^2.0.0