lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Jorge Visca <xxopxe@gmail.com> writes:

> I was wondering what people use as seeds for the random generator.
> os.time() seems ok, but the to-the-second precission and my usage
> patterns make this a risky option. Not very probable, but when it
> happens it means very weird behaviour.
> I'm on linux, and the ideal would be lua only solution, with no extra
> libraries. I could parse MAC adresses from runing "ifconfig", and hash
> them. Or somehow get a number from /dev/urandom... Sadly, "date +%N"
> doesn't work on my platform. Any ideas?

Better take /dev/random if you are out for a _good_ seed and are worried
about "risky".  In particular if you need just a few bytes.
/dev/urandom is designed to compromise on entropy rather than speed.

-- 
David Kastrup