Skip to content


Subversion checkout URL

You can clone with
Download ZIP
An xxhash binding for node.js
C++ JavaScript Python
Branch: master
Failed to load latest commit information.
deps/xxhash Mega update:
lib Mega update:
src Mega update:
LICENSE upgrade xxhash to r6 Mega update:
binding.gyp Mega update:
package.json bump version


An xxhash binding for node.js.



npm install xxhash


  • 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);

  .on('data', function(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);

  .on('finish', function() {
    console.log('Hash value = ' +;


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.