Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An xxhash binding for node.js
C++ JavaScript Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
deps/xxhash Mega update:
lib Mega update:
src Mega update:
LICENSE upgrade xxhash to r6
README.md Mega update:
binding.gyp Mega update:
package.json bump version

README.md

Description

An xxhash binding for node.js.

Requirements

Install

npm install xxhash

Examples

  • Hash a file in one step:
var XXHash = require('xxhash'),
    fs = require('fs');

var file = fs.readFileSync('somefile'),
    result = XXHash.hash(file, 0xCAFEBABE);
  • Hash a file in multiple steps:
var XXHash = require('xxhash'),
    fs = require('fs');

var hasher = new XXHash(0xCAFEBABE);

fs.createReadStream('somefile')
  .on('data', function(data) {
    hasher.update(data);
  })
  .on('end', function() {
    console.log('Hash value = ' + hasher.digest());
  });
  • Hash a file with a hash stream:
var HashStream = require('xxhash').Stream,
    fs = require('fs');

var hasher = new HashStream(0xCAFEBABE);

fs.createReadStream('somefile')
  .pipe(hasher)
  .on('finish', function() {
    console.log('Hash value = ' + hasher.read());
  });

API

XXHash Static Methods

  • hash(< Buffer >data, < integer >seed) - integer - Performs a single/one-time hash of data with the given seed. The resulting hash is returned.

XXHash Static Properties

  • Stream - DuplexStream - A stream constructor that takes in the seed to use. Write data to the stream and when the stream ends, the hash value is available on the readable side as an integer.

XXHash Methods

  • (constructor)(< Integer >seed) - Create and return a new Hash instance that uses the given seed.

  • update(< Buffer >data) - (void) - Update the hash using data. Note: the length of data must be a positive signed integer (e.g. 0 to 2,147,483,647 bytes).

  • digest() - integer - Completes the hashing and returns the resulting integer hash. Note: hash object can not be used after digest() method been called.

Something went wrong with that request. Please try again.