Skip to content

Datamosh-js/seeder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@datamosh-js/seeder License: MIT code style: standard

Standarized seed generation and validation for Datamosh.

Seeder is not idempotent; it uses the current timestamp when creating the seed.

Example:

const { seeder } = require('@datamosh-js/seeder')
seeder('really', () => 'interesting', { arguments: ':)' })
// '21620145'

Needing something a bit longer...

const { seeder512 } = require('@datamosh-js/seeder')
seeder512('really', ['really'], { cool: 'args' })
// '33a6b55f2df7d44c24544193f302e76e31a44c1e2ce1c2621d3077a8c6b7d177b1c0bd08bd2319bb16aa2556197ffcd5f521d228865599eecc6645d53f44fd12'

Usage

seeder(...arguments?)

Makes a 4 byte hexadecimal hash

  • arguments <any>: String coercible metadata used when generating the seed
  • Returns: seed <String>: 4 byte hexadecimal hash

seeder512(...arguments?)

Makes a SHA512 hexadecimal hash

  • arguments <any>: String coercible metadata used when generating the seed
  • Returns: seed <String>: SHA512 hexadecimal hash

validate(seed, nibbles?)

Validate seed from seeder

  • arguments <any>: Seed to validate
  • nibbles <Number>: Expected hex nibble count
  • Returns: result <Boolean>: The validation status true/false