Closed Neonit closed 6 years ago
When no seed is passed in data
is undefined.
https://github.com/davidbau/seedrandom/blob/released/lib/alea.js#L82
It should probably be set to empty string in that scenario.
As user of the library, I'd expect it to choose a random seed. At least something like Date.now().toString()
. Or the same that Math.seedrandom()
does. I'd say defaulting to an empty string is rather counter-intuitive and maybe even dangerous (because users wouldn't expect it to be the same every time).
It looks like there's an autoseed function for the default algorithm but not in the additional ones, i.e. alea, xor128, etc.
https://github.com/davidbau/seedrandom/blob/released/seedrandom.js#L194
Yes. What I wanted to suggest was to set alea
(and others) to use a random seed from autoseed
(or elsewhere) instead of setting it to use an empty string, if no seed is given.
Autoseeding has lots of (hidden security) implications, and I've never been very happy with the original seedrandom's (slow, not very secure) autoseeding.
The idea is that it should throw an exception so that programmers know they need to supply a seed.
Is it intended that
alea()
doesn't work without passing a seed? Calling it without arguments produces an error.Test code (tested on npm.runkit.com using version 2.4.3):