trying to find a fully-random number generator trying to find a fully-random number generator unix unix

trying to find a fully-random number generator


Seed your RNG with a good source of entropy.

Under unix, use /dev/random.

Under windows, use something like CryptoAPI - Windows equivalent of /dev/random


What you are asking for is not a random number generator, but how to use the random number generator already included in the C standard library.

All you need to do is seed it once at program startup:

srand(time(NULL));

That's all. It's portable and will give you a different sequence every time you run the program, given that at least one second has passed since the last time you've ran it.

There is no harm in seeding it again later, but no point in it either.


The C standard library has the header time.h (or ctime if you are using C++)(reference). The functions there will be supported in Windows and Unix.

I would recommend time() or clock() as seed for your random number generator.

An other way to get totally random input is the usage of the mouse position or other things influenced from outside.