diff options
author | Kim Alvefur <zash@zash.se> | 2021-12-02 00:13:23 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-12-02 00:13:23 +0100 |
commit | b332a2aa42b611f82dc487d67ab727f2bfc96478 (patch) | |
tree | b26bf23728c9c6a8b01cce5ffd253fb714ff4ef7 /util/id.lua | |
parent | a3ea469ed9ebeab2c4db54712f0b8ace3f28e15f (diff) | |
download | prosody-b332a2aa42b611f82dc487d67ab727f2bfc96478.tar.gz prosody-b332a2aa42b611f82dc487d67ab727f2bfc96478.zip |
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.
Diffstat (limited to 'util/id.lua')
-rw-r--r-- | util/id.lua | 3 |
1 files changed, 3 insertions, 0 deletions
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; |