From 29d7fecd4b85f1d26370fb9c8268c6635d8601b5 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Sun, 21 Nov 2021 12:10:55 -0500 Subject: [PATCH] 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. --- lock.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lock.lua b/lock.lua index 1823406..f811441 100644 --- a/lock.lua +++ b/lock.lua @@ -39,7 +39,8 @@ local exports = {} local function get_next_lock_id() -- Generate 64 random bits and encode them in hexadecimal: return string.format("%08x%08x", - rng:next() + 2147483648, rng:next() + 2147483648) + rng:next() + 2147483648, + rng:next(0, 131071) * 32768 + math.random(0, 32767)) end -- Returns whether the named player is an admin of the node owned as given.