Re: Good random numbers in PG? And crypto-wishlist

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Dr(dot) Evil" <drevil(at)sidereal(dot)kz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Good random numbers in PG? And crypto-wishlist
Date: 2001-07-26 12:36:20
Message-ID: 20010726073620.A16217@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 26, 2001 at 05:02:30AM -0000,
"Dr. Evil" <drevil(at)sidereal(dot)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/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message matthieuclavier 2001-07-26 14:51:13 memory problems with freebsd
Previous Message Ivan Uemlianin 2001-07-26 09:47:06 Some questions on using arrays.