Hazz
Hazz, a pseudo-random-data-filled-table to generate k indipendent and uniform, very fast (non-cryptographic) hash functions.
If you need to hash arbitrary long length inputs, without using a fixed (big) size pseudo-random table, a fast way is to simulate a set of indipendent hash functions using a single crpyto-digest (with a sha-512 digest we can simulate up to 16 functions). Take a look to Mazz (the fast way of the tonto).
Install
$ npm install hazz [-g]
require:
var Hazz = require( 'hazz' );
Run Tests
to run all test files, install devDependencies:
$ cd hazz/
$ npm install
$ npm test
to execute a single test file simply do:
$ node test/file-name.js
Constructor
Specify how many bytes to parse (at max), from every
input key to hash, then the number of functions to use.
NOTE:
- default value for input length is 16 byte.
- default and minimum value for hfn is 2
Arguments between [] are optional.
Hazz( [ Number max_input_length [, Number hfn ] ] )
new Hazz( [ Number max_input_length [, Number hfn ] ] )
Properties
Hazz.table
Hazz.ilength
Hazz.hfn
Methods
Arguments between [] are optional.
Hazz#refill() : Hazz
Hazz#do( Number hfn, Buffer data [, Number range ] ) : Number
Hazz#all( Buffer data [, Number range ] ) : Array
See examples.
MIT License
Copyright (c) 2017-present < Guglielmo Ferri : 44gatti@gmail.com >
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.