Saturday, March 9, 2024

UUID (Universally Unique Identifier)

UUID stands for Universally Unique Identifier. It is a 128-bit identifier standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE). UUIDs are used to uniquely identify information in computer systems and across distributed systems. UUIDs are represented by 32(x4=128) hexadecimal digits, like this : eaf20a8a-7687-4acb-8253-218682888dd8 In many computer systems and programming languages, timestamps are represented using the Unix time format, also known as POSIX time or Unix epoch time. This format represents time as the number of seconds (or milliseconds) that have elapsed since midnight Coordinated Universal Time (UTC) on January 1, 1970 (the Unix epoch). For example, the current Unix time at the time of writing (March 8, 2024) would be a large number of seconds (or milliseconds) since January 1, 1970. In programming languages like Python, JavaScript, Java, etc., timestamps are often represented as integers or floating-point numbers, indicating the number of seconds (or milliseconds) since the Unix epoch. Using 64 bits (double precision floating-point or a long integer) is common for this level of precision. UUIDs version 1 is grouped into five sections

  1. Time Low: The first 32 bits of the UUID, representing the low 32 bits of the timestamp.
  2. Time Mid: The next 16 bits of the UUID, representing the middle 16 bits of the timestamp.
  3. Time High and Version: The next 16 bits of the UUID, representing the high 16 bits of the timestamp, along with a version number (indicating the UUID version).
  4. Clock Sequence and Variant: The next 8 bits of the UUID, representing the clock sequence (used for UUIDs generated within the same timestamp) and variant bits. The process of generating the clock sequence typically involves generating a random or pseudo-random number of 14 bits in length.
Node: The last 48 bits of the UUID, representing the node identifier, typically the MAC address of the computer generating the UUID. UUID Version 2 (Domain Identifier-Based): UUID version 2 is similar to version 1 but includes a domain identifier, the clock sequence field is combined with the domain identifier to ensure uniqueness within the same domain and timestamp. UUID Version 3 and 5 (Name-Based): Versions 3 and 5 UUIDs are based on hashing a namespace identifier and name to produce a UUID. Version 3 uses MD5 hashing, while version 5 uses SHA-1 hashing. They ensure reproducibility, meaning the same namespace and name input will always produce the same UUID output. Version 5 is considered more secure due to the use of the SHA-1 hashing algorithm. UUID Version 4 (Random): Version 4 UUIDs are entirely random and do not rely on any algorithm or source of information other than random number generation. They are generated using cryptographically secure random number generators, ensuring a very low probability of collision. This property makes UUID Version 4 ideal for situations where uniqueness and unpredictability are crucial, such as in cryptographic applications or distributed systems. Cryptographically secure random number generators (CSPRNGs) are algorithms designed to generate random numbers that are suitable for use in cryptographic applications. Their canonical textual representation is a series of 32 hexadecimal characters which are separated into five groups by hyphens in the form 8-4-4-4-12.


No comments: