On Thu, Jul 26, 2001 at 05:02:30AM -0000,
  "Dr. Evil" <[EMAIL PROTECTED]> 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/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to