[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Getting randomic integers
- From: Klaus Ripke <paul-lua@...>
- Date: Sun, 17 Jan 2010 14:13:37 +0100
On Sun, Jan 17, 2010 at 10:15:41AM +0000, startx wrote:
> i was just wondering, what if someone does something like this:
>
> local devrandom = io.open("/dev/urandom","r")
right, nowadays random and urandom devices seem to be
widely available on systems having /dev/
> local size = 64
> local seed = devrandom:read(size)
> devrandom:close()
>
> math.randomseed(string.byte(seed))
well, better to read and use 4 byte?
> print(math.random(100))
>
> you could even use /dev/random if your systenm is busy enough to have a
> sufficient feed for /dev/random, or am i completely wrong here?
You should use random only for things like generating new keys.
For programs that should not block use urandom,
it's as good possible without blocking on linux and solaris
and apparently makes no difference at all on BSD/OSX.
For the randum number generator,
pick one according to your requirements.
E.g. many have very good distribution properties,
but next values are rather predictable once you know a sequence,
which may be a no-go.
best
Klaus