https://github.com/giovannicalo/node-xxhash
Node xxHash
https://github.com/giovannicalo/node-xxhash
hash node xxhash
Last synced: 8 months ago
JSON representation
Node xxHash
- Host: GitHub
- URL: https://github.com/giovannicalo/node-xxhash
- Owner: giovannicalo
- License: mit
- Created: 2022-10-19T01:20:03.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-15T01:10:28.000Z (over 1 year ago)
- Last Synced: 2025-02-09T08:35:55.932Z (9 months ago)
- Topics: hash, node, xxhash
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Node xxHash
[](https://github.com/giovannicalo/node-xxhash/actions/workflows/build.yml)
[](https://coveralls.io/github/giovannicalo/node-xxhash)
## Prerequisites
* [CMake](https://cmake.org) >= 3.21.0
## Installation
```bash
npm install giovannicalo/node-xxhash
```
> Not yet published to NPM. This will install it from GitHub.
## Usage
```javascript
const { xxh3, xxh32, xxh64, xxh128 } = require("xxhash");
const data = Buffer.from("foo");
console.log(xxh3(data));
// 3792637401
console.log(xxh32(data));
// 3728699739546630719n
console.log(xxh64(data));
// 12352915711150947722n
console.log(xxh128(data));
//
```
## API
### `xxh3(data: Buffer, seed: bigint = 0n): bigint`
Hashes the `data` `Buffer` using xxHash XXH3 with `seed`, defaulting to `0n`.
Returns the hash as a `bigint`.
### `xxh32(data: Buffer, seed: number = 0): number`
Hashes the `data` `Buffer` using xxHash XXH32 with `seed`, defaulting to `0`.
Returns the hash as a `number`.
### `xxh64(data: Buffer, seed: bigint = 0n): bigint`
Hashes the `data` `Buffer` using xxHash XXH64 with `seed`, defaulting to `0n`.
Returns the hash as a `bigint`.
### `xxh128(data: Buffer, seed: bigint = 0n): Buffer`
Hashes the `data` `Buffer` using xxHash XXH128 with `seed`, defaulting to `0n`.
Returns the hash as a 16-byte `Buffer`.