From b332a2aa42b611f82dc487d67ab727f2bfc96478 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 2 Dec 2021 00:13:23 +0100 Subject: util.id: Add a 'tiny' variant Conversations uses this for its randomized resources. Presumably fine and collision resistant enough when you have a few devices at most. --- util/id.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util') diff --git a/util/id.lua b/util/id.lua index 64b56662..ff4e919d 100644 --- a/util/id.lua +++ b/util/id.lua @@ -19,6 +19,9 @@ end return { -- sizes divisible by 3 fit nicely into base64 without padding== + -- for short lived things with low risk of collisions + tiny = function() return b64url_random(3); end; + -- close to 8 bytes, should be good enough for relatively short lived or uses -- scoped by host or users, half the size of an uuid short = function() return b64url_random(9); end; -- cgit v1.2.3