Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sindresorhus/string-hash

sindresorhus28.6kMIT2.0.0TypeScript support: included

Get the hash of a string

string, hash, code, hashcode, hash-code, fnv1a, fnv-1a, fnv, algorithm, hashing, function

readme

string-hash

Get the hash of a string

Uses the non-cryptographic hash function FNV-1a.

Similar to Java's String#hashCode().

Install

$ npm install @sindresorhus/string-hash

Usage

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

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

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

It returns the hash as a positive integer.