How Uuid Is Generated?

Version-1 UUIDs are generated from a time and a node ID (usually the MAC address); version-2 UUIDs are generated from an identifier (usually a group or user ID), time, and a node ID; versions 3 and 5 produce deterministic UUIDs generated by hashing a namespace identifier and name; and version-4 UUIDs are generated ...

How many UUID can be generated?

Each character can be a digit 0 through 9, or letter a through f. 32 hexadecimals x log2(16) bits/hexadecimal = 128 bits in a UUID. In the version 4, variant 1 type of UUID, 6 bits are fixed and the remaining 122 bits are randomly generated, for a total of 2¹²² possible UUIDs.

How do you generate a random UUID?

The following example generates a random UUID.
  1. import java.util.UUID;
  2. public class UUIDExample.
  3. {
  4. public static void main(String[] args)
  5. {
  6. UUID uuid=UUID.randomUUID(); //Generates random UUID.
  7. System.out.println(uuid);
  8. }
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.