Mix more randomness into key codes

Continuously using math.random should tap into the unpredictable usages
of other mods. I limited the number at 2^15-1 to make sure the call
works with Lua 5.1 when INT_MAX is 2^15-1.
This commit is contained in:
Jude Melton-Houghton 2021-11-21 12:10:55 -05:00
parent 3640844c1f
commit 29d7fecd4b

View File

@ -39,7 +39,8 @@ local exports = {}
local function get_next_lock_id() local function get_next_lock_id()
-- Generate 64 random bits and encode them in hexadecimal: -- Generate 64 random bits and encode them in hexadecimal:
return string.format("%08x%08x", return string.format("%08x%08x",
rng:next() + 2147483648, rng:next() + 2147483648) rng:next() + 2147483648,
rng:next(0, 131071) * 32768 + math.random(0, 32767))
end end
-- Returns whether the named player is an admin of the node owned as given. -- Returns whether the named player is an admin of the node owned as given.