util.id
This module provides randomized strings for use as identifiers. Often you might reach for UUID for this, but sometimes you might want a smaller or more compact representation. That’s where this module comes in! The URL-safe Base64 character set is used.
The exact amount of entropy produced by these functions may be adjusted, do not depend on the exact format.
tiny
Appropriate for avoiding naming conflicts of internally managed and short-lived objects.
.tiny() --> PuLh id
short
Appropriate for generating identifiers for relatively short-lived objects.
.short() --> f72wMeZO6JfT id
medium
Appropriate for globally unique identifiers of objects with long lifetime, as well as secret tokens. Meant to be equivalent but more compact to an UUID.
.medium() --> 7GnAYG898D453tfZcm8mU5tB id
long
Appropriate for very secret tokens, insane overkill for most uses.
.long() --> 6_MvvkXVpHgMs_oGDuQnjipvSIXIjnd5GH7D id
custom
Appropriate for when you just want to have more control over the amount of entropy in the IDs. Takes the number of octets of entropy to procure as argument and returns a function that returns an id with that much entropy.
.custom(6) --> function () --> z_mXz-fJ id