jeudi 23 avril 2020

Random Number Generator that allows me to access the "seed" whenever I want

I am using NodeJs and need a cryptographically secure random number generator. I have tried researching and finding various ways to generate these secure numbers, and I have been using the npm module 'secure-random' but now I have a new requirement that I must be able to print out what seed was used everytime I print out a random number. I am unsure how to do that with the current module and was hoping someone could either direct me to a different library to use as I've searched for hours, or guide me on actually making a function myself. Currently I have a function that looks like:

function roll(min,max){
var data = secureRandom.randomUint8Array(1);
data = data[0]/(Math.pow(2,8)-1)
data = Math.floor(data * (max - min + 1) + min);
return data
}

But now I need a function that creates a secure random number and allows me to return the seed as well for every iteration of the function.

Thank you for the help




Aucun commentaire:

Enregistrer un commentaire