# @bitgo/blake2b-wasm

> Blake2b implemented in WASM

Latest version **3.2.3** (published 2023-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bitgo/blake2b-wasm
pnpm add @bitgo/blake2b-wasm
yarn add @bitgo/blake2b-wasm
bun add @bitgo/blake2b-wasm
```

## Health

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

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.2.3 |
| Published | 2023-08-04 |
| First published | 2021-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 132.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 395 |
| Author | Mathias Buus |
| Maintainers | mohammadalfaiyaz_bitgo, alebusse, zahin-mohammad, mkottaichamy, margueriteblair, islamaminbitgo, pranavjain, joshdk, johntzanakakisbitgo, mmcshinsky-bitgo, bitgoaaron, ericcrosson-bitgo, dhoffmann |

## Links

- npm: https://www.npmjs.com/package/@bitgo/blake2b-wasm
- Repository: https://github.com/BitGo/BitGoJS
- Homepage: https://github.com/mafintosh/blake2b-wasm
- Issues: https://github.com/mafintosh/blake2b-wasm/issues
- npm.io page: https://npm.io/package/@bitgo/blake2b-wasm

## Dependencies (1)

- [nanoassert](https://npm.io/package/nanoassert.md) ^1.0.0

## Recent versions

- 3.2.3 (latest) — 2023-08-04
- 3.0.4-rc.0 (rc) — 2022-07-26
- 3.1.0-dev.0 (dev) — 2022-06-18
- 3.2.2 — 2023-07-28
- 3.2.1 — 2023-07-18
- 3.2.0 — 2022-10-18
- 3.0.4 — 2022-09-30
- 3.0.3 — 2022-07-19
- 3.0.3-rc.0 — 2022-06-07
- 3.0.2 — 2022-02-08
- 3.0.2-rc.0 — 2021-12-23
- 3.0.1 — 2021-08-10
- 3.0.1-rc.0 — 2021-08-06
- 3.0.0 — 2021-04-22
- 3.0.0-rc.2 — 2021-04-12
- … 1 more at https://npm.io/package/@bitgo/blake2b-wasm/versions

## README

# blake2b-wasm

Blake2b implemented in WASM

```
npm install @bitgo/blake2b-wasm
```

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

## Usage

```js
var blake2b = require('@bitgo/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.

#### `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.
The format of this file is S-Expressions that can be compiled to their binary WASM representation by doing

```
wat2wasm blake2b.wat -o blake2b.wasm
```

To build the thin JavaScript wrapper for the WASM module use `wat2js`:

```
# also available as `npm run compile`
wat2js blake2b.wat -o blake2b.js
```

If you do not have `wat2wasm` installed follow the instructions here, https://github.com/WebAssembly/wabt

## License

MIT

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