@pacote/xxhash

Fast non-cryptographic hashing algorithm.

Usage no npm install needed!

<script type="module">
  import pacoteXxhash from 'https://cdn.skypack.dev/@pacote/xxhash';
</script>

README

@pacote/xxhash

version minified minified + gzip

Fast non-cryptographic hashing algorithm.

Installation

yarn add @pacote/xxhash

Usage

import { xxh64 } from '@pacote/xxhash'

const hasher = xxh64(2654435761)

hasher.update('data').digest('hex') // => '5014607643a9b4c3'

xxh64(seed?: number | U64): XXHash

xxh64() creates a XXHash64 hasher instance with an optional seed. If not provided, the seed value is 0.

XXHash#update(data: string | ArrayBuffer): XXHash

Updates the hasher state with data from a string or buffer to hash.

The hasher instance is returned for chaining other methods.

XXHash#digest(encoding: 'hex'): string

Outputs the hexadecimal hash of the provided data. The only encoding value allowed at this time is 'hex'.

XXHash#reset(seed?: number | U64): void

Resets the hasher state with an optional seed. If a seed is not provided, then the value remains the one used the last time the hasher was either created or reset.

License

MIT © Luís Rodrigues.