mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Merge pull request #140 from apreiml/fix
make sure we got enough random bytes
This commit is contained in:
commit
d40bfe438f
1 changed files with 5 additions and 1 deletions
6
init.lua
6
init.lua
|
@ -36,7 +36,11 @@ end
|
||||||
|
|
||||||
-- Efficient function to get a random string
|
-- Efficient function to get a random string
|
||||||
function random_string()
|
function random_string()
|
||||||
local random_bytes = io.open("/dev/urandom"):read(64);
|
local length = 64
|
||||||
|
local random_bytes = io.open("/dev/urandom"):read(length);
|
||||||
|
if string.len(random_bytes) ~= length then
|
||||||
|
error("Not enough random bytes read")
|
||||||
|
end
|
||||||
return tohex(random_bytes);
|
return tohex(random_bytes);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue