1.0.12 • Published 5 months ago

hash-maker v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

hash-maker

A collection of hash and number generators for Node or Browser in pure JS.

  • SHA - Creates a SHA1/224/256/384/512 hash of a message.
  • MD5 - Creates a MD5 hash of a message.
  • CRC - Createsa CRC3/16/32 hash of a message.
  • UUID - Create UUIDs verisons 1 - 5.
  • Random bytes - Random bytes of a supplied length (based on Mersenne Twister)
  • Mersenne Twister - Random number generator that can be seaded. Create 32 bit signed, unsigned or float values.
  • Random Xor Shift - Random number generator that can be seaded. Creates unsigned 32 bit values.

Installation

npm install hash-maker

Provides both CommonJS and ES modules.

SHA

SHA hash function. All SHA functions can be returned as a string, Uint8Array, Buffer or Hex string (default).

Can be imported as:

const { SHA256 } = require('hash-maker');
//
import { SHA256 } from 'hash-maker';
const hash = SHA256("0123456789",{asArray:true});

MD5

MD5 hash function. MD5 functions can be returned as a string, Uint8Array, Buffer or Hex string (default).

Can be imported as:

const { MD5 } = require('hash-maker');
//
import { MD5 } from 'hash-maker';
const hash = MD5("0123456789",{asArray:true})

CRC

CRC hash function. CRC functions can be returned as a Hex string, Uint8Array, Buffer or number (default).

Can be imported as:

const { CRC32 } = require('hash-maker');
//
import { CRC32 } from 'hash-maker';
const hash = CRC32("0123456789",{asArray:true});

UUID

UUID generator function. UUID functions can create verisons 1 - 5 (default 4) and can be returned as a Uint8Array, Buffer or Hex string (default).

Can be imported as:

const { UUID } = require('hash-maker');
//
import { UUID } from 'hash-maker';
const id = UUID(1,{asArray:true});

Random Bytes

Random byte generator function. Functions can be returned as a Buffer or Uint8Array (default). Numbers generated with the Mersenne Twister (see below).

Can be imported as:

const { randomBytes } = require('hash-maker');
//
import { randomBytes } from 'hash-maker';
const bytes = randomBytes(12,true);

Mersenne Twister

Mersenne Twister number generator class. Can be seeded with a number or Uint32Array.

Can be imported as:

const { MERSENNETWISTER } = require('hash-maker');
//
import { MERSENNETWISTER } from 'hash-maker';
const seed; // number or Uint32Array if needed
const mt = new MERSENNETWISTER(seed);
const unsignedInt = mt.genrand_int32() // or mt.RandTwisterUnsigned() mt.random_int()
const signedInt = mt.genrand_int32i() // or mt.RandTwisterSigned()
const unsigned31Int = mt.genrand_int3i() //31 bit number
const double = mt.genrand_real1() // or mt.RandTwisterDouble()
const float1 = mt.genrand_real2() // generates a random number on [0,1)-real-interval
const float2 = mt.genrand_real3() // generates a random number on (0,1)-real-interval
const float3 = mt.genrand_res53() // generates a random number on [0,1) with 53-bit resolution

Random Xor Shift

Random Xor Shift number generator class. Can seeded with a number or a Uint8Array or Buffer of 4 bytes.

Can be imported as:

const { RANDOMXORSHIFT } = require('hash-maker');
//
import { RANDOMXORSHIFT } from 'hash-maker';
const seed; //number, Uint8Array or Buffer of 4 bytes
const rxs = new RANDOMXORSHIFT(seed);
const random_int = rxs.random_int();
1.0.11

5 months ago

1.0.12

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.10

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago