wyhash.js
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

wyhash.js

A port of wyhash to JavaScript, with TypeScript type definitions.

wyhash is a fast and solid non-cryptographic hash function. Its code is relatively simple and system-independent (endianness and bitness), making it easy to correctly port to and generate consistent hashes from many different languages and platforms.

A simpler API is provided, while all original functions and constants are available under the internal exported object.

Usage

Add this to your project:

npm i wyhash.js

Use the simpler API:

import { Wyhash } from "wyhash.js";

const seed = 42n;
const hasher = new Wyhash(seed);
const h1 = hasher.hash("Hello!");
const h2 = hasher.hash(new Uint8Array([3, 5, 8]));

See main.ts for the full API.

Use the internal API:

import { internal } from "wyhash.js";

const data = new TextEncoder().encode("Hello");
const secret: internal.Secret = internal._wyp;
const h = internal.wyhash(data, 42n, secret);

See internal.ts for the full API.

Readme

Keywords

none

Package Sidebar

Install

npm i wyhash.js

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

15.5 kB

Total Files

6

Last publish

Collaborators

  • wilsonzlin