Skip to main content

Quick non-cryptographic hash functions for strings

Works with
This package works with Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
76%
Published
a month ago (0.0.3)

dumbjs/quick-hash

Why?

Tired of copying them around

Usage

The library exports a few quick string hashing functions that are widely used for proper bit distribution and short hashes for longer strings, (with the exception of the BigInt implementation of sdbm)

dbj2

Details →

import { dbj2 as hash } from '@dumbjs/quick-hash'
// or
// import { dbj2 as hash } from '@dumbjs/quick-hash/dbj2'

hash('hello') //=>261238937

sdbm

Details →

Original Version

import { sdbm as hash } from '@dumbjs/quick-hash'
// or
// import { sdbm as hash } from '@dumbjs/quick-hash/sdbm'

hash('hello') //=>31334377934759990

GAWK Version

import { sdbmGawk as hash } from '@dumbjs/quick-hash'
// or
// import { sdbmGawk as hash } from '@dumbjs/quick-hash/sdbm'

hash('hello') //=>1925877435333486942514

License

MIT

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @dumbjs/quick-hash

Import symbol

import * as mod from "@dumbjs/quick-hash";

Add Package

npx jsr add @dumbjs/quick-hash

Import symbol

import * as mod from "@dumbjs/quick-hash";

Add Package

yarn dlx jsr add @dumbjs/quick-hash

Import symbol

import * as mod from "@dumbjs/quick-hash";

Add Package

pnpm dlx jsr add @dumbjs/quick-hash

Import symbol

import * as mod from "@dumbjs/quick-hash";

Add Package

bunx jsr add @dumbjs/quick-hash

Import symbol

import * as mod from "@dumbjs/quick-hash";