Description
GenRocket provides three Universally Unique Identifier or UUID Generators that can be used to generate random, pattern-based, or time-based UUIDs.
In This Article
- What is a UUID?
- Are There Different Types of UUIDs?
- When are UUIDs Used?
- Real-World Usage Example
- Available UUID Generators
What is a UUID?
- UUID stands for Universally Unique Identifier
- UUID is also used comparatively with Global Unique Identifier (GUID).
- It is a 128-bit unique reference label that identifies information within a system, application, or physical object.
- Represented as 32 hexadecimal characters with hyphens.
- Example: 8e127176-f674-481e-a398-2e5a191e7c63
Are There Different Types of UUIDs?
Yes, there are five different versions (or types):
- Version 1 - Time-based
- Version 2 - DCE Security
- Version 3 - Name-based (MD5)
- Version 4 - Random
- Version 5 - Name-based (SHA-1)
When are UUIDs Used?
UUIDs have a low probability of being repeated and provide a way to ensure that a value is unique, making them useful for the following purposes (among others):
- Primary Keys in Databases
- Physical Hardware Identifiers
- System Instances
- Unique File Names
Real-World Usage Example
Let's say you have a User table within a database where the User Id is the primary key and has been assigned starting at '1'. As the business grows, additional services are added, and that User Id is stored as a foreign key in other database tables.
Your business merges with another company that has followed the same practices in its databases. Now a single User Id can point to two separate user records in the system. This can be avoided when UUIDs are used as the unique identifier for primary keys within a database.
Available UUID Generators
The following UUID Generators are currently available:
Generator Name | Description | When to Use |
UUIDGen | Generates a Type 4 universally unique identifier. This means that the six most significant bits are used for some type of information, and the remaining 122 bits are assigned randomly. So the most significant half of the UUID contains 58 bits of randomness, which means one would, on average, need to generate 2^29 UUIDs to get a collision (compared to 2^61 for the full UUID) | Generate a random, unique UUID (Version 4). |
UUIDSeedGen | Requires that five groups of UUID be seeded with a start value. The generated result will be treated as a hexadecimal number. The generator will increment the value on each iteration starting from Group 5. | Generate a unique UUID where you control the data's pattern. |
UUIDTimeBasedGen | Produces time-based UUIDs. It requires a startDate to generate the first timestamp. Group 1 of the UUID increments by one each iteration. Groups 4 and 5 generate randomly. When a seed is given, Groups 4 and 5 will generate the same random data each time data is generated. | Generate time-based UUIDs (Version 1). |