Re: How to make a random number
> On Wed, Apr 26, 2000 at 07:44:35PM -0500, Oleg Krivosheev wrote:
> > no idea who D&D are but the best way IMO
> > is to feed srand off /dev/urandom
> Depends on what you want. For most thing, secure randomness isn't
> nessecary, so the entropy buffers should be saved for when it is
> neccesary. /dev/urandom is also a Linux phonemon, and kills portability
> if used indiscrimitiely.
Portability issues aside...
Reading one number off of /dev/urandom does not drain the entropy pool
that much, but using it to seed srand() is kind of overkill.
srand/rand are not all that random to begin with.
I would suggest:
If you just want a few random numbers, and do not care how good they
are, go with srand(3)/rand(3).
If you want higher quality random numbers, but you do not need truely
random, entropy-laden numbers (most people do not need truly random
numbers), go with srandom(3)/random(3).
If you need truly random numbers for cryptographic work, then consider
/dev/urandom or /dev/random.
> David Starner - firstname.lastname@example.org
> The hell that is supposedly out there could be no worse than
> the hell that is sometimes seen in here.
> To UNSUBSCRIBE, email to email@example.com
> with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org
Buddha Buck email@example.com
"Just as the strength of the Internet is chaos, so the strength of our
liberty depends upon the chaos and cacophony of the unfettered speech
the First Amendment protects." -- A.L.A. v. U.S. Dept. of Justice