Skip to main content

A fast, simple xxHash64 (and XXH3) implementation in TypeScript/WASM.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
70%
Published
2 weeks ago (2.0.0)

xxHash64

A fast, simple xxHash64 (and XXH3) implementation in TypeScript/WASM.

Example

import * as XXH64 from "https://deno.land/x/xxhash64/mod.ts"

let h = await XXH64.create()
h.update('abc')
h.digest() // #=> Uint8Array(8) [ 68, 188, ... ]
h.digest('bigint') // #=> 11027476751619767364n
h.digest('hex') // #=> "44bc2cf5ad770999"

// Continue updating/digesting a hash...
h.update('xyz').digest('hex') // #=> "19434a35e8bf0983"
h.update('xyz').digest('hex') // #=> "578474f682ca960f"

// Reset to generate a new hash:
h.reset().update('xyz').digest('hex') // #=> "feba48465b833ca1"

// Combine reset/update/digest in one call:
h.hash('xyz', 'hex') // #=> "feba48465b833ca1"

// Improved XXH3 64-bit algorithm...
let h3 = await XXH64.create3()
h3.hash('xyz', 'hex') // #=> "6276d2656f411f1f"
h3.hash('abc', 'bigint') // #=> 5780703864653066104n

// Reseeding...
const seed = new Uint8Array([1,0,0,0,0,0,0,0])
h3.reseed(seed).update('xyz').digest('hex') // #=> d819f2585dc69106

References

License

This project is licensed under the terms of the MIT license and others.

Add Package

deno add @jabr/xxhash64

Import symbol

import * as mod from "@jabr/xxhash64/";

Add Package

npx jsr add @jabr/xxhash64

Import symbol

import * as mod from "@jabr/xxhash64/";

Add Package

yarn dlx jsr add @jabr/xxhash64

Import symbol

import * as mod from "@jabr/xxhash64/";

Add Package

pnpm dlx jsr add @jabr/xxhash64

Import symbol

import * as mod from "@jabr/xxhash64/";

Add Package

bunx jsr add @jabr/xxhash64

Import symbol

import * as mod from "@jabr/xxhash64/";