mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
make sure we got enough random bytes
This commit is contained in:
parent
0c55f38fda
commit
1159322c35
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
|
||||
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);
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue