WebAssembly implementation of Google FarmHash. This module began life as a quasi-fork of the farmhash module.
'use strict';
const {
hash32,
hash32WithSeed,
hash64,
hash64WithSeed,
hash64WithSeeds,
fingerprint32,
fingerprint64
} = require('farmhash.wasm');
console.log(hash32('foobar'));
console.log(hash32(Buffer.from('foobar')));
console.log(hash32WithSeed('foobar', 128));
console.log(hash32WithSeed(Buffer.from('foobar'), 128));
console.log(hash64('foobar'));
console.log(hash64(Buffer.from('foobar')));
console.log(hash64WithSeed('foobar', 0));
console.log(hash64WithSeed(Buffer.from('foobar'), 0));
console.log(hash64WithSeeds('foobar', 0, 0));
console.log(hash64WithSeeds(Buffer.from('foobar'), 0, 0));
console.log(fingerprint32('foobar'));
console.log(fingerprint32(Buffer.from('foobar')));
console.log(fingerprint64('foobar'));
console.log(fingerprint64(Buffer.from('foobar')));
farmhash.wasm
exports the following methods.
- Arguments
input
(string or Buffer) - Value to be hashed.
- Returns
result
(number) - A 32-bit unsigned integer hash value ofinput
.
- Arguments
input
(string or Buffer) - Value to be hashed.seed
(integer) - Number to use as a seed.
- Returns
result
(number) - A 32-bit unsigned integer hash value ofinput
.
- Arguments
input
(string or Buffer) - Value to be hashed.
- Returns
result
(string) - A string representation of a 64-bit unsigned integer hash value ofinput
.
- Arguments
input
(string or Buffer) - Value to be hashed.seed
(integer) - Number to use as a seed.
- Returns
result
(string) - A string representation of a 64-bit unsigned integer hash value ofinput
.
- Arguments
input
(string or Buffer) - Value to be hashed.seed1
andseed2
(integer) - Numbers to use as a seed.
- Returns
result
(string) - A string representation of a 64-bit unsigned integer hash value ofinput
.
- Arguments
input
(string or Buffer) - Value to fingerprint.
- Returns
result
(number) - A 32-bit unsigned integer fingerprint value ofinput
.
- Arguments
input
(string or Buffer) - Value to fingerprint.
- Returns
result
(number) - A string representation of a 64-bit unsigned integer fingerprint value ofinput
.