Re: Good random numbers in PG? And crypto-wishlist
От | Bruno Wolff III |
---|---|
Тема | Re: Good random numbers in PG? And crypto-wishlist |
Дата | |
Msg-id | 20010726073620.A16217@wolff.to обсуждение исходный текст |
Ответ на | Good random numbers in PG? And crypto-wishlist ("Dr. Evil" <drevil@sidereal.kz>) |
Список | 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 по дате отправления: