https://github.com/rootslab/mazz
Mazz, the fast way of the tonto, to simulate 16 indipendent hash functions, using a crypto digest.
https://github.com/rootslab/mazz
bloom-filter dunce-hash hash hashing
Last synced: about 1 year ago
JSON representation
Mazz, the fast way of the tonto, to simulate 16 indipendent hash functions, using a crypto digest.
- Host: GitHub
- URL: https://github.com/rootslab/mazz
- Owner: rootslab
- License: mit
- Created: 2017-11-16T13:15:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-06T20:24:54.000Z (over 8 years ago)
- Last Synced: 2025-03-15T05:08:15.133Z (about 1 year ago)
- Topics: bloom-filter, dunce-hash, hash, hashing
- Language: JavaScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
### Mazz
[](https://www.npmjs.org/package/mazz)
[](https://www.codacy.com/public/44gatti/mazz)
[](https://codeclimate.com/github/rootslab/mazz)
[](https://github.com/rootslab/mazz#mit-license)

[](http://travis-ci.org/rootslab/mazz)
[](https://david-dm.org/rootslab/mazz)
[](https://david-dm.org/rootslab/mazz#info=devDependencies)
[](http://npm-stat.com/charts.html?package=mazz)

[](http://npm-stat.com/charts.html?package=mazz)
[](https://nodei.co/npm/mazz/)
> __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](https://github.com/rootslab/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
```bash
$ npm install mazz [-g]
```
> __require__:
```javascript
var Mazz = require( 'mazz' );
```
### Run Tests
> __to run all test files, install devDependencies:__
```bash
$ cd mazz/
# install or update devDependencies
$ npm install
# run tests
$ npm test
```
> __to execute a single test file simply do__:
```bash
$ node test/file-name.js
```
### Constructor
> No reason to create multiple instances (results are the same).
```javascript
var Mazz = require( 'mazz' );
, h = Mazz.do( .. )
```
### Properties
```javascript
/*
* total number of hash functions
*/
Mazz.hfn
```
### Methods
> Arguments between [] are optional.
```javascript
/*
* 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](example/).
### 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.
[](https://github.com/igrigorik/ga-beacon)