Socket
Socket
Sign inDemoInstall

xxhash-wasm

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xxhash-wasm

A WebAssembly implementation of xxHash


Version published
Weekly downloads
1M
increased by2.08%
Maintainers
1
Weekly downloads
 
Created

What is xxhash-wasm?

The xxhash-wasm npm package provides a WebAssembly (WASM) implementation of the xxHash algorithm, which is known for its high speed and excellent hash quality. This package allows you to compute hash values for strings and binary data efficiently in JavaScript environments.

What are xxhash-wasm's main functionalities?

Hashing a string

This feature allows you to compute 32-bit and 64-bit hash values for a given string. The example demonstrates how to hash the string 'Hello, world!' with a seed value of 0xABCD.

const { xxhash32, xxhash64 } = require('xxhash-wasm');

(async () => {
  const { h32, h64 } = await xxhash32();
  const hash32 = h32('Hello, world!', 0xABCD);
  console.log(`32-bit hash: ${hash32}`);

  const { h64 } = await xxhash64();
  const hash64 = h64('Hello, world!', 0xABCD);
  console.log(`64-bit hash: ${hash64}`);
})();

Hashing binary data

This feature allows you to compute 32-bit and 64-bit hash values for binary data. The example demonstrates how to hash a Uint8Array with a seed value of 0xABCD.

const { xxhash32, xxhash64 } = require('xxhash-wasm');

(async () => {
  const { h32, h64 } = await xxhash32();
  const buffer = new Uint8Array([1, 2, 3, 4, 5]);
  const hash32 = h32(buffer, 0xABCD);
  console.log(`32-bit hash: ${hash32}`);

  const { h64 } = await xxhash64();
  const hash64 = h64(buffer, 0xABCD);
  console.log(`64-bit hash: ${hash64}`);
})();

Other packages similar to xxhash-wasm

Keywords

FAQs

Package last updated on 02 Nov 2022

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