Merge 0.10->trunk
[prosody.git] / util / random.lua
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         urandom:flush();
14 end
15
16 local function bytes(n)
17         return urandom:read(n);
18 end
19
20 return {
21         seed = seed;
22         bytes = bytes;
23 };