xxhash

An xxhash binding for node.js

npm install xxhash
25 downloads in the last day
94 downloads in the last week
397 downloads in the last month

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 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());
  });

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 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.

npm loves you