Generating a sequence of $n$-bit random-like numbers that will never repeat.

206 Views Asked by At

I am actually aiming for n $\approx 100$ but obviously I could interleave the bits of two never-repeating $50$-bit sequences etc.

I need to be able to generate the $n^{th}$ number quickly enough to seem instantaneous to a human. After that, finding the $(n+1)^{th}$ should be trivial.

Given a large number of the already generated numbers I need it to be difficult to reproduce the algorithm I am using.

1

There are 1 best solutions below

11
On BEST ANSWER

You can't generate a list of $n$ bit numbers that never repeats because there are only $2^n$ of them. It must repeat within that time.

Probably the easiest way to generate them is to use some very simple random number generator like a linear congruential one, and hash the result.

Added: A Linear Feedback Shift Register seems to do what you want. You could build one in software of length $100$ bits. It will avoid all collisions. It looks like predicting the output from a number of successive outputs is quite easy, but you could run it through your favorite encryption algorithm. The Advanced Encryption Standard has a version that outputs 128 bits. If that is too many, you could find a pair of 49/50 bit primes and do RSA encryption