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 = io.open("/dev/urandom", "r");
10
 
11
if urandom then
12
	return {
13
		seed = function () end;
14
		bytes = function (n) return urandom:read(n); end
15
	};
16
end
17
 
18
local crypto = require "crypto"
19
return crypto.rand;