From owner-freebsd-questions@FreeBSD.ORG Wed May 25 03:06:52 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EED8D16A41C for ; Wed, 25 May 2005 03:06:52 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.45]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1C2543D48 for ; Wed, 25 May 2005 03:06:52 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from mac.com (smtpin07-en2 [10.13.10.152]) by smtpout.mac.com (Xserve/8.12.11/smtpout11/MantshX 4.0) with ESMTP id j4P36qq5017658; Tue, 24 May 2005 20:06:52 -0700 (PDT) Received: from [192.168.1.6] (pool-68-161-53-96.ny325.east.verizon.net [68.161.53.96]) (authenticated bits=0) by mac.com (Xserve/smtpin07/MantshX 4.0) with ESMTP id j4P36n8K029470; Tue, 24 May 2005 20:06:51 -0700 (PDT) In-Reply-To: <200505242113.54226.nb_root@videotron.ca> References: <200505242113.54226.nb_root@videotron.ca> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <6AA64B10-7064-44AA-A98A-F7F68BBF0F41@mac.com> Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Tue, 24 May 2005 23:06:44 -0400 To: Nicolas Blais X-Mailer: Apple Mail (2.730) Cc: freebsd-questions@freebsd.org Subject: Re: srandomdev() vs srandom() vs arc4random() X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2005 03:06:53 -0000 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