What is the best and fastest algorithm to generate cryptographically secure PRNG? My requirements is as follows.
- In each run, I need to generate few millions of numbers with length of 10.
- It should not allow one to predict future iterations by observing some number of iterations.
- Numbers should be unique. No duplicates allowed.
- Speed is also important since it will generate millions of numbers in each iteration.
I checked Mersenne Twister algorithm but it seems it is not cryptographically secure. They said, it could be predicted by checking 624 iterations.
P.S. It would be better if there is a Java Implementation.
Your unique requirement means that you cannot use any sort of RNG (my earlier comment was wrong), since random numbers will include repeats. Instead, use a cipher and encrypt the numbers: 0, 1, 2, 3, ... which will give guaranteed unique results. Since ciphers are reversible, each cyphertext decrypts back to the original plaintext, so the cyphertexts are a permutation of the plaintexts.
You also want numbers of "length ten". I assume this means ten decimal digits, [1,000,000,000 .. 9,999,999,999]. That means you need a cipher which works in the range [0 .. 8,999,999,999], and just add 1e9 to the output.
That is more complex. Either use the Hasty Pudding cipher, which can be set for any range of numbers you want, or roll your own Feistel cipher with its block size set to the next higher power of 2. If a number is out of range then re-encrypt it until it is in range. The Feistel option will be faster, but less secure. You can make it more secure by increasing the number of rounds at the cost of making it slower.