Introduction to UUID Basics

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.