From e630418372cf5ee48e5c24e22e011d07bbcee25d Mon Sep 17 00:00:00 2001 From: rhy <81539300+rhynomatt@users.noreply.github.com> Date: Mon, 9 Jan 2023 12:06:07 -0300 Subject: [PATCH] uuid: Add a passed rng to uuid4 --- uuid.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uuid.lua b/uuid.lua index aaced33..c4f07c1 100644 --- a/uuid.lua +++ b/uuid.lua @@ -20,11 +20,11 @@ end local uuid4_template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" --generate a UUID version 4 (random) -function uuid.uuid4() +function uuid.uuid4(rng) return uuid4_template:gsub("[xy]", function (c) -- x should be 0x0-0xF, the single y should be 0x8-0xB -- 4 should always just be 4 (denoting uuid version) - return string.format("%x", c == "x" and _random(0x0, 0xF) or _random(0x8, 0xB)) + return string.format("%x", c == "x" and _random(0x0, 0xF, rng) or _random(0x8, 0xB, rng)) end) end