Blake2b.prototype.update = function (input: Uint8Array) {
if (!(input instanceof Uint8Array))
- throw new TypeError('input must be Uint8Array or Buffer')
+ throw new TypeError(`input must be Uint8Array or Buffer`)
blake2bUpdate(this, input)
return this
}
Blake2b.prototype.digest = function (out?: 'binary' | 'hex' | Uint8Array) {
var buf = (!out || out === 'binary' || out === 'hex') ? new Uint8Array(this.outlen) : out
if (!(buf instanceof Uint8Array))
- throw new TypeError('out must be "binary", "hex", Uint8Array, or Buffer')
+ throw new TypeError(`out must be "binary", "hex", Uint8Array, or Buffer`)
if (buf.length < this.outlen)
- throw new RangeError('out must have at least outlen bytes of space')
+ throw new RangeError(`out must have at least outlen bytes of space`)
blake2bFinal(this, buf)
if (out === 'hex') return hexSlice(buf)
return buf
export default function createHash (outlen: number, key?: Uint8Array, salt?: Uint8Array, personal?: Uint8Array, noAssert?: boolean) {
if (noAssert !== true) {
if (outlen < BYTES_MIN)
- throw new RangeError('outlen must be at least ' + BYTES_MIN + ', was given ' + outlen)
+ throw new RangeError(`outlen must be at least ${BYTES_MIN}, was given ${outlen}`)
if (outlen > BYTES_MAX)
- throw new RangeError('outlen must be at most ' + BYTES_MAX + ', was given ' + outlen)
+ throw new RangeError(`outlen must be at most ${BYTES_MAX}, was given ${outlen}`)
if (key != null) {
if (!(key instanceof Uint8Array))
- throw new TypeError('key must be Uint8Array or Buffer')
+ throw new TypeError(`key must be Uint8Array or Buffer`)
if (key.length < KEYBYTES_MIN)
- throw new RangeError('key must be at least ' + KEYBYTES_MIN + ', was given ' + key.length)
+ throw new RangeError(`key must be at least ${KEYBYTES_MIN}, was given ${key.length}`)
if (key.length > KEYBYTES_MAX)
- throw new RangeError('key must be at most ' + KEYBYTES_MAX + ', was given ' + key.length)
+ throw new RangeError(`key must be at most ${KEYBYTES_MAX}, was given ${key.length}`)
}
if (salt != null) {
if (!(salt instanceof Uint8Array))
- throw new TypeError('salt must be Uint8Array or Buffer')
+ throw new TypeError(`salt must be Uint8Array or Buffer`)
if (salt.length !== SALTBYTES)
- throw new RangeError('salt must be exactly ' + SALTBYTES + ', was given ' + salt.length)
+ throw new RangeError(`salt must be exactly ${SALTBYTES}, was given ${salt.length}`)
}
if (personal != null) {
if (!(personal instanceof Uint8Array))
- throw new TypeError('personal must be Uint8Array or Buffer')
+ throw new TypeError(`personal must be Uint8Array or Buffer`)
if (personal.length !== PERSONALBYTES)
- throw new RangeError('personal must be exactly ' + PERSONALBYTES + ', was given ' + personal.length)
+ throw new RangeError(`personal must be exactly ${PERSONALBYTES}, was given ${personal.length}`)
}
}