Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 May 2005 23:06:44 -0400
From:      Charles Swiger <cswiger@mac.com>
To:        Nicolas Blais <nb_root@videotron.ca>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: srandomdev() vs srandom() vs arc4random()
Message-ID:  <6AA64B10-7064-44AA-A98A-F7F68BBF0F41@mac.com>
In-Reply-To: <200505242113.54226.nb_root@videotron.ca>
References:  <200505242113.54226.nb_root@videotron.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On May 24, 2005, at 9:13 PM, Nicolas Blais wrote:
> I would like to know how "random" (that is, how inprobable a  
> pattern will
> appear) if I use srandom(time(NULL)) instead of srandomdev().
> Also, would arc4random() be any better in getting the least pattern  
> creation.
> Finally, is there is a way to check if the call srandomdev() exists  
> on other
> OSes?

srandom() is an adequate RNG, but it tends to have poor distribution  
of numbers (ie, specific bit patterns are more likely than others).   
You might want to consider the Mersenne Twister RNG:

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

...which has appeared under both a GPL and a BSD-flavored license  
over it's history.

-- 
-Chuck





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6AA64B10-7064-44AA-A98A-F7F68BBF0F41>