# @sindresorhus/string-hash

> Get the hash of a string

Latest version **2.0.0** (published 2021-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sindresorhus/string-hash
pnpm add @sindresorhus/string-hash
yarn add @sindresorhus/string-hash
bun add @sindresorhus/string-hash
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-08-22 |
| First published | 2018-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/sindresorhus__string-hash) |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 68 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | string, hash, code, hashcode, hash-code, fnv1a, fnv-1a, fnv, algorithm, hashing, function |

## Links

- npm: https://www.npmjs.com/package/@sindresorhus/string-hash
- Repository: https://github.com/sindresorhus/string-hash
- Homepage: https://github.com/sindresorhus/string-hash#readme
- Issues: https://github.com/sindresorhus/string-hash/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/@sindresorhus/string-hash

## Dependencies (1)

- [@sindresorhus/fnv1a](https://npm.io/package/@sindresorhus/fnv1a.md) ^3.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2021-08-22
- 1.2.0 — 2019-03-31
- 1.1.0 — 2019-03-18
- 1.0.0 — 2018-01-07

## README

# string-hash

> Get the hash of a string

Uses the non-cryptographic hash function [FNV-1a](https://github.com/sindresorhus/fnv1a).

Similar to Java's [`String#hashCode()`](https://en.m.wikipedia.org/wiki/Java_hashCode()).

## Install

```
$ npm install @sindresorhus/string-hash
```

## Usage

```js
import stringHash from '@sindresorhus/string-hash';

stringHash('🦄🌈');
//=> 2868248295

stringHash('👌😎');
//=> 2903279002
```

It returns the hash as a positive integer.

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