mazz

0.2.1 • Public • Published

Mazz

NPM VERSION CODACY BADGE CODECLIMATE-TEST-COVERAGE LICENSE

NODE VERSION TRAVIS CI BUILD BUILD STATUS DEVDEPENDENCY STATUS

NPM MONTHLY NPM YEARLY NPM TOTAL

NPM GRAPH

Mazz, the fast way of the tonto, to simulate 16 indipendent hash functions, using a crypto digest. If you need a set of independent pseudo-random hash functions, try Hazz.

PROS:

  • you can hash inputs of arbitrary length ( > 64 bytes ) with the best performances
  • no random table in memory, like Hazz

CONS:

  • the maximum number of hash functions are 16 (from index 0 to 15), if u need more (or less) try Hazz
  • the same input produces the same result every time, no pseudo-randomness was involved for generating functions results ( the k-th hash function applied to the same input i produces an unique result).
  • it is slower than Hazz for inputs ~<= 64 bytes
  • integers produced are between the range [ 2^24, 2^32 - 1 ]

Install

$ npm install mazz [-g]

require:

var Mazz  = require( 'mazz' );

Run Tests

to run all test files, install devDependencies:

 $ cd mazz/
 # install or update devDependencies 
 $ npm install 
 # run tests 
 $ npm test

to execute a single test file simply do:

 $ node test/file-name.js

Constructor

No reason to create multiple instances (results are the same).

var Mazz  = require( 'mazz' );
    , h = Mazz.do( .. )

Properties

/*
 * total number of hash functions  
 */
Mazz.hfn

Methods

Arguments between [] are optional.

 
/*
 * Specify a positive integer (from 0 to 15) to use the i-th
 * hash function. If specified it returns a number within a
 * range.
 * NOTE: the minimum range is obviously 2 (0, 1).
 */
Mazz#do( Number hfn, Buffer data [, Number range ] ) : Number
 
/*
 * hash with all functions in parallel,
 * it returns an array of results
 */
Mazz#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.

GA

Readme

Keywords

Package Sidebar

Install

npm i mazz

Weekly Downloads

5

Version

0.2.1

License

MIT

Last publish

Collaborators

  • rootslab