🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

node-clhash

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-clhash

Bindings for the CLHash C API to the Node.js world

1.2.1
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

node-clhash

Node.js library that provides bindings for the CLHash C library (https://github.com/lemire/clhash).

⚠️ The package compilation requirements are the same as the CLHash library requirements (see https://github.com/lemire/clhash#requirements).

To install the package run the following command:

$ npm install node-clhash
# Or if you use yarn
$ yarn add node-clhash

The get_random_key_for_clhash uses posix_memalign internally and needs to be the key pointer to be aligned. The library does not expose binding for the get_random_key_for_clhash and doesn't allow the user to generate its key. Instead, it generates the key and then the hashed value and returns both values to the user:

const { clhash } = require('node-clhash');
// Generate synchronously.
const { key, hashed } = clhash.sync('my long string');
console.log({ key, hashed }); // { key: 5067639175440424385n, hashed: 8451564168848164053n }

// Generate asynchronously.
clhash('my long string', (error, { key, hashed }) => {
  console.log({ key, hashed }); // { key: 5067639175440424385n, hashed: 8451564168848164053n }
});

The key and hashed values are BigInt. The clhash returns uint64_t, which is unsigned long long. The maximum uint64_t value is 2 ^ 64 - 1 and the maximum JavaScript integer value is 2 ^ 53 - 1 (Number.MAX_SAFE_INTEGER).

Keywords

clhash

FAQs

Package last updated on 10 May 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