Introduction to UUID Basics
1. What is a UUID?
The UUID is a universally unique identifier (universally unique Identifier). Composed of 128bit, if used in 16 notation, then it is 32 characters. The representation is as follows: 03e1c09e-4967-469c-85f5-764c5b286d47 (8-4-4-4-12).
The role of 2.UUID?
Allows all elements in a distributed system to have unique identification information, without having to use the central control to specify the information.
What elements of 3.UUID are made to make it unique?
A UUID is a number generated on a machine that is guaranteed to be unique to all machines in the same time and space. One thing that makes sense is that it guarantees that it can generate a unique string at some point in a certain machine.
Part:
1) Current date and time
2) Clock sequence
3) Globally unique IEEE machine identification number.
4. How do I create a UUID in Java?
Creating a UUID in Java is as simple as using the static method provided by the Java.util.UUID class (a total of 3) to create the UUID.
method 1:uuid.randomuuid (); Use random generation to generate a random UUID , call version (), return 4;
method 2:uuid.fromstring ("03e1c09e-4967-469c-85f5-764c5b286d47"); The random generation produces a specified UUID, call version (), return 4;
Method 3:uuid.nameuuidfrombytes ("03e1c09e-4967-469c-85f5-764c5b286d47". GetBytes ()); Using the name method to produce a UUID, call version (), return 3;
One thing to add: There are 4 ways to generate a UUID:
Version Value:1 represents the time-based generation
Version VALUE:2 indicates DCE security UUID
Version Value:3 indicates that the build by name
Version Value:4 indicates random generation
These 4 generation methods are represented by 1,2,3,4 and can be used to obtain this value using version (). For example, using Uuid.randomuuid () to generate a UUID, the call to the version () method would give the number 4, indicating that the UUID was generated randomly.
Introduction to UUID Basics