# metrohash

> Node.js bindings for MetroHash hashing library

Latest version **3.2.0** (published 2026-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install metrohash
pnpm add metrohash
yarn add metrohash
bun add metrohash
```

## Health

**Score 55/100 (C)** — status: active.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2026-04-12 |
| First published | 2015-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 67 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 27 |
| Author | Robert Klep |
| Maintainers | robertklep |

## Links

- npm: https://www.npmjs.com/package/metrohash
- Repository: https://github.com/robertklep/node-metrohash
- Homepage: https://github.com/robertklep/node-metrohash#readme
- Issues: https://github.com/robertklep/node-metrohash/issues
- npm.io page: https://npm.io/package/metrohash

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) ^2.25.0
- [bindings](https://npm.io/package/bindings.md) ^1.5.0
- [node-gyp](https://npm.io/package/node-gyp.md) ^10.3.1

## Recent versions

- 3.2.0 (latest) — 2026-04-12
- 3.1.0 — 2026-03-17
- 3.0.0 — 2025-01-22
- 2.8.0 — 2021-06-25
- 2.7.0 — 2021-06-05
- 2.6.0 — 2019-04-30
- 2.5.1 — 2019-01-08
- 2.5.0 — 2018-08-09
- 2.4.2 — 2018-07-25
- 2.4.1 — 2018-07-11
- 2.4.0 — 2018-05-02
- 2.3.0 — 2017-06-15
- 2.2.0 — 2017-04-11
- 2.1.0 — 2017-01-31
- 2.0.1 — 2017-01-09
- … 9 more at https://npm.io/package/metrohash/versions

## README

# node-metrohash

Wrapper around [MetroHash](https://github.com/jandrewrogers/MetroHash).

[![Build Status](https://travis-ci.org/robertklep/node-metrohash.svg)](https://travis-ci.org/robertklep/node-metrohash)
[![Build status](https://ci.appveyor.com/api/projects/status/49944yng9l70q41k/branch/master?svg=true)](https://ci.appveyor.com/project/robertklep/node-metrohash/branch/master)

### Installation

```
$ npm install metrohash
```

### API change!

Between v1 and v2, the API for this library has changed to allow for maximum hashing speed.

The biggest change is that a calculated hash is now returned as a (hex-encoded) string instead of a `Buffer`.

If a `Buffer` is still required, it's easy to convert the string:

```
let buffer = Buffer.from(metrohash64('input'), 'hex');
```

Also, the `.hash()` methods for the hasher classes have been removed in favor of standalone functions (see below).

### Usage

The module exports 2 classes, `MetroHash64` and `MetroHash128`, and two functions, `metrohash64` and `metrohash128`.

The classes are meant for incremental hashing, the functions for standalone hash calculations.

The class constructors and functions accept an optional `seed` numerical argument, which defaults to `0`.

#### Class interface

``` javascript
const MetroHash64 = require('metrohash').MetroHash64;

// Constructor.
MetroHash64(seed? : number) : this

// Update.
MetroHash64#update(input : String | Buffer) : this

// Finalize and get hash digest.
MetroHash64#digest() : String
```

(likewise for `MetroHash128`).

#### Function interface

```
const metrohash64 = require('metrohash').metrohash64;

metrohash64(input : String | Buffer, seed? : number) : String
```

(likewise for `metrohash128`).

### Examples

``` javascript
//// Classes

const MetroHash64 = require('metrohash').MetroHash64;

// Instantiate using seed 123 (`new` is optional).
let hash = new MetroHash64(123);

// Update using a string as input.
hash.update('Hello, World!');

// The same as above:
// hash.update('Hello, ').update('World!');

// Finalize to get the digest as a hex string.
let digest = hash.digest();

//// Functions
const metrohash64 = require('metrohash').metrohash64;

let digest = metrohash64('Hello, World!', 123);
```

### Speed

From v2.0 onwards, MetroHash is [pretty fast](https://medium.com/@drainingsun/in-search-of-a-good-node-js-hashing-algorithm-8052b6923a3b).

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