xxhash-nan

0.9.0 • Public • Published

xxhash-nan

An xxhash binding for node.js. Forked from the original to add compatibility with future versions of node via NAN.

on npm Tests Dependencies

Installation

You must be running node 0.8 or later. (Thanks to an npm 2.0 compatibility issue, travis tests fail on 0.8.)

npm install xxhash

Examples

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

Hash a file incrementally:

var XXHash = require('xxhash-nan'),
    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 module functions

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

Package Sidebar

Install

npm i xxhash-nan

Weekly Downloads

1

Version

0.9.0

License

MIT

Last publish

Collaborators

  • ceejbot