⬅️ Web Development 🔗 Stack Overflow
-
UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier), according to RFC 4122, are identifiers designed to provide certain uniqueness guarantees.
-
UUIDS, are 128 bit numbers, composed of 16 octets and represented as 32 base-16 characters, that can be used to identify information across a computer system
-
It’s a 36-character alphanumeric string that can be used to identify information
-
crypto.randomUUID()
is now standard on all modern browsers and JS runtimes. However, because new browser APIs are restricted to secure contexts, this method is only available to pages served locally (localhost
or127.0.0.1
) or over HTTPS. -
for generating UUIDs on legacy platforms or in non-secure contexts, there is the
uuid
module. It is well-tested and supported.
If everything else fails, then use this one
Note: solutions based on Math.random()
do not provide good uniqueness guarantees.
Uuid Format
- UUIDs must be of the form “
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
”, where x is one of [0-9, a-f] M is one of [1-5], and N is [8, 9, a, or b]