Newbie School: how to obtain UUID in Linux

Source: Internet
Author: User

In Linux, there are commands dedicated to UUID generation:

Uuidgen [-r] [-t].

A 32-bit string can be generated. This is obtained in the command line. There is a/uuid. h in/usr/include/lib, which defines the data uuid and the unsigned character pointer. Uuid_generate (uuid_t uu) is a function dedicated to UUID generation. The UUID generated is placed in the parameter UU. The result is an 8-digit hexadecimal number.

During the UUID generation function, after some processing, the 8-bit hexadecimal number is generated. The reason is that during the generation process, originally, a 32-bit long integer is generated. The result is converted to an 8-bit hexadecimal number through uid_parse. Instead, we have the uuid_unparse function, which can reverse convert the hexadecimal number to a 32-bit integer.

Note:When compiling uuid functions in linux, we need to connect the database, that is, add a-luuid. Full Form:

Gcc-o uuid. c-luuid

At the same time, we need to allocate space reasonably when defining the 32-bit long integer string for saving the transformation. The most insecure way is to apply for a pointer to store one character, so do not avoid doing so!

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.