# hmac-blake2b

> HMAC backed by BLAKE2b

Latest version **2.0.2** (published 2023-01-12) · ISC license · 0 weekly downloads

## Install

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

## 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.0.2 |
| Published | 2023-01-12 |
| First published | 2018-04-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/hmac-blake2b) |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Emil Bay |
| Maintainers | emilbayes |
| Keywords | hmac, blake2b |

## Links

- npm: https://www.npmjs.com/package/hmac-blake2b
- Repository: https://github.com/emilbayes/hmac-blake2b
- Homepage: https://github.com/emilbayes/hmac-blake2b#readme
- Issues: https://github.com/emilbayes/hmac-blake2b/issues
- npm.io page: https://npm.io/package/hmac-blake2b

## Dependencies (2)

- [nanoassert](https://npm.io/package/nanoassert.md) ^2.0.0
- [sodium-universal](https://npm.io/package/sodium-universal.md) ^4.0.0

## Recent versions

- 2.0.2 (latest) — 2023-01-12
- 2.0.0 — 2020-06-25
- 1.0.0 — 2020-05-01
- 0.2.0 — 2018-04-26
- 0.1.1 — 2018-04-25
- 0.1.0 — 2018-04-25

## README

# `hmac-blake2b`

[![Build Status](https://github.com/emilbayes/hmac-blake2b/actions/workflows/npm.yml/badge.svg)](https://github.com/emilbayes/hmac-blake2b/actions/workflows/npm.yml)

> HMAC based on BLAKE2b

Even though BLAKE2b is designed to also work as a MAC, specifications like
[Noise](http://noiseprotocol.org/noise.html#hash-functions-and-hashing) call for
a HMAC.

## Usage

```js
const { randombytes_buf } = require('sodium-universal/randombytes')
const hmac = require('.')

const mac = Buffer.alloc(hmac.BYTES)
const key = Buffer.alloc(hmac.KEYBYTES)
randombytes_buf(key)

const data = Buffer.from('some data')

hmac(mac, data, key)

```

## API

### `hmac.BYTES`

Size of the output MAC in bytes

### `hmac.KEYBYTES`

[RFC2104](https://www.ietf.org/rfc/rfc2104.txt) recommended size of the key in
bytes.

### `hmac(out, data, key)`

Computes a HMAC from `data` with `key` and writes it into `out`.

* `out` must be a `Buffer` or `Uint8Array` of length `hmac.BYTES`
* `data` must be a `Buffer`, `Uint8Array` or `Array` of `Buffer`s or
  `Uint8Array`s.
* `key` must be a `Buffer` or `Uint8Array`. Per the HMAC spec `key` can be as
  small as 1 byte, in which case it is right-padded with `NUL` bytes, or any
  size larger than `hmac.KEYBYTES` in which case it is hashed down to fit. The
  recommended size by the spec is `hmac.KEYBYTES`

## Install

```sh
npm install hmac-blake2b
```

## License

[ISC](LICENSE)

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