Search code examples
integerrandomsequenceprng

Pseudorandom Sequence Generator not just a number generator


I need an algorithm that pretty much will turn a unix timestamp into a suitably random number, so that if I "play back" the timestamps I get the same random numbers.

And here's what I mean by suitably:

  1. Most humans will not detect a loop or pattern in the random numbers.
  2. It need not be cryptographically secure.
  3. All numbers must be capable of being generated. (I've found that LFSR don't do this)
  4. The numbers are 32 bit integers

And I would like it to be fairly fast.

So far my idea is to just seed a PRNG over and over, but I'm not sure if that's the best way to handle this.

Any thoughts and ideas will be much appreciated.

Thanks.


Solution

  • If it doesn't need to be statistically random, perhaps feed the timestamps to MD5 and truncate the hash. The main issue is that I don't know if this would be surjective. Other hashing algorithms might work better.