Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xxhashjs

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xxhashjs

xxHash in Javascript

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
increased by6.05%
Maintainers
1
Weekly downloads
 
Created

What is xxhashjs?

The xxhashjs npm package is a pure JavaScript implementation of the XXHash algorithm, which is a fast non-cryptographic hash algorithm. It is used primarily for generating consistent hash values of data, such as strings or binary content, with high performance.

What are xxhashjs's main functionalities?

Hashing a string

This feature allows you to hash a string using the XXHash algorithm with a specified seed. The result is a hash value that can be used for checksums, fingerprinting, or other purposes where a unique identifier for data is needed.

"use strict";
const XXH = require('xxhashjs');
const H = XXH.h32(0xABCD) // seed = 0xABCD
const buf = new Buffer('hello world');
const hash = H.update(buf).digest().toString(16); // hash is a hexadecimal string
console.log(hash);

Hashing a file stream

This feature demonstrates how to hash the contents of a file stream. As the stream is read, chunks are continuously updated to the hash function, and the final hash value is computed at the end of the stream.

"use strict";
const fs = require('fs');
const XXH = require('xxhashjs');
const H = XXH.h32(0xABCD);
const stream = fs.createReadStream('example.txt');
stream.on('data', function (chunk) {
  H.update(chunk);
});
stream.on('end', function () {
  const hash = H.digest().toString(16);
  console.log(hash);
});

Other packages similar to xxhashjs

Keywords

FAQs

Package last updated on 18 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc