Releases: dchest/blake2s-js
Releases · dchest/blake2s-js
v1.3.0
v1.2.2
v1.2.1
- Fixed config validation: instance constructor was supposed to check that
key
,salt
, andpersonalization
wereUint8Array
orArray
and throw otherwise, however due to an error this check didn't work. - Use The Unlicense for public domain dedication.
v1.2.0 — Salting and personalization support
To create salted and/or personalized hash instance, you can now pass a config object to BLAKE2s constructor instead of key (passing just key is still supported) with the following optional fields:
{
salt: // 8-byte Uint8Array or Array of bytes
personalization: // 8-byte Uint8Array or Array of bytes
key: // 0-32-byte Uint8Array or Array of bytes
}
If present, salt
and personalization
must each have exactly 8 bytes, while key
field, as previously, can have from 0 to 32 bytes (it will be zero-padded if has fewer than 32 bytes).
Examples
Salting and personalizing:
var randomSalt = new Uint8Array(BLAKE2.saltLength);
window.crypto.getRandomValues(randomSalt);
var h = new BLAKE2s(32, {
salt: randomSalt,
personalization: Uint8Array([1, 0, 0, 0, 0, 0, 0, 0])
});
...
Passing just a key still works:
var key = new Uint8Array(BLAKE2s.keyLength);
window.crypto.getRandomValues(key);
var h = new BLAKE2s(32, key);
...
If config contains unknown key, an error will be thrown. This is helpful to protect against misspellings.