Re: Good random numbers in PG? And crypto-wishlist - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Good random numbers in PG? And crypto-wishlist
Date
Msg-id 20010726073620.A16217@wolff.to
Whole thread Raw
In response to Good random numbers in PG? And crypto-wishlist  ("Dr. Evil" <drevil@sidereal.kz>)
List pgsql-general
On Thu, Jul 26, 2001 at 05:02:30AM -0000,
  "Dr. Evil" <drevil@sidereal.kz> wrote:
>
> I'm writing an application that requires cryptographicly-sound random
> decimal digits in PG.  One way to do this is with a plain old hash
> like SHA1.  The problem is that this produces a 20 byte string, when
> what I want is a digit from 0 to 9.  One thing I could do is take this
> 20 byte string, and return the first 8 bytes of it as a INT8, and take
> the mod10 of it.  That should be mostly random.  Is this a good way to
> do it?  Or is there some better way?

This isn't necessarily useful for making it work in postgres, but I have
a way to get uniform random distributions from uniformily distributed
binary numbers. This is for a die roll server and uses the output from
/dev/random as the source of uniformly distributed binary numbers.
The module that does this part can be found at:
http://wolff.to/dice/Roll.pm
For more information on the dice server see:
http://wolff.to/dice/

pgsql-general by date:

Previous
From: Joel Burton
Date:
Subject: Re: diff's between creations of tables
Next
From: matthieuclavier@mageos.com
Date:
Subject: memory problems with freebsd