# blake2b-wasm

> Blake2b implemented in WASM

Latest version **2.4.0** (published 2021-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install blake2b-wasm
pnpm add blake2b-wasm
yarn add blake2b-wasm
bun add blake2b-wasm
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.0 |
| Published | 2021-11-22 |
| First published | 2017-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/blake2b-wasm) |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 123 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 77 |
| Author | Mathias Buus |
| Maintainers | mafintosh, emilbayes |

## Links

- npm: https://www.npmjs.com/package/blake2b-wasm
- Repository: https://github.com/mafintosh/blake2b-wasm
- Issues: https://github.com/mafintosh/blake2b-wasm/issues
- npm.io page: https://npm.io/package/blake2b-wasm

## Dependencies (2)

- [b4a](https://npm.io/package/b4a.md) ^1.0.1
- [nanoassert](https://npm.io/package/nanoassert.md) ^2.0.0

## Recent versions

- 2.4.0 (latest) — 2021-11-22
- 2.3.0 — 2021-09-01
- 2.2.0 — 2021-05-25
- 2.1.0 — 2019-09-03
- 1.1.7 — 2018-01-22
- 1.1.6 — 2018-01-22
- 1.1.5 — 2018-01-20
- 1.1.4 — 2017-09-15
- 1.1.3 — 2017-06-15
- 1.1.2 — 2017-06-11
- 1.1.1 — 2017-06-11
- 1.1.0 — 2017-06-11
- 1.0.0 — 2017-06-08
- 0.0.0 — 2017-06-08

## README

# blake2b-wasm

Blake2b implemented in WASM

```
npm install blake2b-wasm
```

Works in browsers that support WASM and Node.js 8+.

## Usage

``` js
var blake2b = require('blake2b-wasm')

if (!blake2b.SUPPORTED) {
  console.log('WebAssembly not supported by your runtime')
}

blake2b.ready(function (err) {
  if (err) throw err

  var hash = blake2b()
    .update(Buffer.from('hello')) // pass in a buffer or uint8array
    .update(Buffer.from(' '))
    .update(Buffer.from('world'))
    .digest('hex')

  console.log('Blake2b hash of "hello world" is %s', hash)
})
```

## API

#### `var hash = blake2b([digestLength], [key], [salt], [personal])`

Create a new hash instance. `digestLength` defaults to `32`.

#### `hash.update(data)`

Update the hash with a new piece of data. `data` should be a buffer or uint8array.

#### `var digest = hash.digest([enc])`

Digest the hash.

#### `hash.getPartialHash()`

Returns the current partial hash.

#### `hash.setPartialHash(data)`

Set the hash to a previously set hash. `data` should be the result of `getPartialHash()` (which returns uint8array)

#### `var promise = blake2b.ready([cb])`

Wait for the WASM code to load. Returns the WebAssembly instance promise as well for convenience.
You have to call this at least once before instantiating the hash.

## Browser demo

There is a browser example included in [example.html](example.html) and [example.js](example.js).

## Contributing

The bulk of this module is implemented in WebAssembly in the [blake2b.wat](blake2b.wat) file. To build the thin Javascript wrapper do:

```
npm run compile
```

## License

MIT

---
_Source: https://npm.io/package/blake2b-wasm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
