in

What is a good way to derive a numbers from random seed?


I have a game I am working on. There is one random seed generated at some point. At later point, I want to use this seed to derive some attributes like attack or defense of a character.

I want attributes to not be correlated to each other. One way I thought of is using hash functions like so:

const attackHex = createHash('md5')
    .update(seed)
    .update('attack')
    .digest('hex')
const attack = Number(attackHex);

console.log('attack', attackHex, attack)

const defenseHex = createHash('md5')
    .update(seed)
    .update('defense')
    .digest('hex')
const defense = Number(defenseHex);

console.log('defense', defenseHex, defense)

Outputs:

attack 73341812d1bd6fc73c022b4971618c27 NaN
defense 0620fbd637b7cf2f7d83dc3c8d5f8528 NaN

But the number conversion is not too happy… I guess it is too big of a number.

I would appreciate any help.



Source: https://stackoverflow.com/questions/70630461/what-is-a-good-way-to-derive-a-numbers-from-random-seed

Facebook Launches ‘Privacy Center’ to Educate Users on Data Collection and Privacy Options

A React hook to fetch ENS records from a domain