

Firstly, hash functions are very good at generating seeds from short strings. There are many ways to do this, but here are two methods.

To avoid this, it is best practice to initialize PRNGs with a well-distributed, high entropy seed and/or advancing past the first 15 or so numbers. a simple seed of 1 and 2) have low entropy, and can cause correlations or other randomness quality issues, sometimes resulting in the output having similar properties (such as randomly generated levels being similar). To keep things simple, the generators below have no built-in seed generating procedure, but accept one or more 32-bit numbers as the initial seed state of the PRNG.
#RANDOM PASSWORD GENERATOR JS CODE#
For example, if you have written JavaScript code that implements an IP-based access control list, then you can generate a bunch of random IPs and check if your code is correct in multiple browsers. These are not intended for security purposes-if you need a seedable CSPRNG, look into ISAAC.įirst of all, take care to initialize your PRNGs properly. Using a Random IP Generator in Cross-browser Testing A random IP generator can be useful if you're doing cross-browser testing. All of them can be seeded and provide high quality numbers.

I've implemented a number of good, short and fast Pseudorandom number generator (PRNG) functions in plain JavaScript. So such a function must be externally provided, which thankfully isn't too difficult. The ECMAScript specification is intentionally vague on the subject, providing no means for seeding nor require that browsers even use the same algorithm. No, it is not possible to seed Math.random().
