Robert Huff <[EMAIL PROTECTED]> writes: > What is the canonical way to get data from /dev/random? > Specifically: having opened the file, how do I read the stream? > I'm currently using > > > union { > float f; > char c[4]; > } foo; > > foo.f = 0.0; > > fscanf(rand_fp,"%4c",foo.c); > > > which doesn't seem to produce anywhere near "random bytes" as > promised by the man page.
Have you turned off the "seeded" variable? You'll fall back to a software pseudorandom sequence if you don't. Most computers don't have all that much real random data ("entropy") to work with, and if you need a lot of random data, you're more or less forced to use a good pseudorandom generator. "Good" can vary a bit depending on application, but random(3) is generally more than good enough for monte carlo style simulation purposes. Cryptography is another story. I have a hardware random number generator on my server, which helps with performance in some cases... -- Lowell Gilbert, embedded/networking software engineer, Boston area http://be-well.ilk.org/~lowell/ _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"