util/random.lua

changeset 9
7da8b3c95bb1
equal deleted inserted replaced
8:2e4c32c4fb6b 9:7da8b3c95bb1
1 -- Prosody IM
2 -- Copyright (C) 2008-2014 Matthew Wild
3 -- Copyright (C) 2008-2014 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9 local urandom = assert(io.open("/dev/urandom", "r+"));
10
11 local function seed(x)
12 urandom:write(x);
13 end
14
15 local function bytes(n)
16 return urandom:read(n);
17 end
18
19 return {
20 seed = seed;
21 bytes = bytes;
22 };

mercurial