Originally posted here by RejectKnowledge
Umm, specificly 16 digits. Lets see:

In C/C++, you can use the rand() or the srand() functions. They won't give you 16 digit random numbers, you'll have to give it any algorithm you like.. for example:

randomnumber1 = srand() * 91234567890;
randomnumber2 = srand() * 99234567890


Basically, all you're doing here is generating a random number, using the 'srand()' function, and then multiplying it with a sufficiently large number. The number, ofcourse, could be anything at all. Just make sure its big. Real big.

Unfortunately, this solution isn't statistically viable:
Multiplying with a constant will limit the range of possible result; for example using 91234567890 or 99234567890 means you will always get a "pseudo-random" number divisible by 10 (or seen in a diffrent way, that ends with 0). In other words, the resulting "pseudo-random" number will always be a multiple of the prime factors of the constant.

A way around this would be to multiply 2 pseudo-random numbers together. This would already be better although I beleive that would also be statistically biased:
Half natural numbers are odd, half are even.
When multiplicating, the only way to obtain an odd number is to multiply two odd numbers.
So, the odds of obtaining an odd number when multipling two random numbers (each with 50% chance of returning an odd number) would yeild only a 25% chance, while it should be 50%...

This might not mean much at first look, but it can be crucial when carefully observed: just take a look at TCP ISN (Initial Sequence Number) prediction for example:
http://razor.bindview.com/publish/papers/tcpseq.html
http://lcamtuf.coredump.cx/newtcp/


Ammo