The UUID Acquisition Method in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. In Linux, The uuidgen [-r] [-t] command is used to generate UUID. 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 a data uuid and a non-Signed 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? 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!
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