npm.io
2.0.0 • Published 5 years ago

@sindresorhus/string-hash

Licence
MIT
Version
2.0.0
Deps
1
Size
3 kB
Vulns
0
Weekly
0
Stars
68

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.

Keywords