Is it possible to insert arbitrary data into UUID? Let's suppose we have an MD5\SHA hash of something... can we encode that data into a valid UUID?
1 Answer
No UUID have a specific structure which doesn't take into account appending any custom user-generated information.
Also consider how bad this idea is, UUID are a type of identification which should somehowe resolve to the actual data, identification is a mean of decoupling the desired entity from the actual content of it. An identification should be unique and unchangeable, while the actual data may change over time.
If you start putting data into the identifier you're messing with the very goal of an identification, being unique and unchangeable.
EDIT:
The version 3 or 5 UUID is meant for generating UUIDs from "names" that are drawn from, and unique within, some "name space". The concept of name and name space should be broadly construed, and not limited to textual names. For example, some name spaces are the domain name system, URLs, ISO Object IDs (OIDs), X.500 Distinguished Names (DNs), and reserved words in a programming language. The mechanisms or conventions used for allocating names and ensuring their uniqueness within their name spaces are beyond the scope of this specification.
Source: http://tools.ietf.org/search/rfc4122 paragraph 4.3
-
1** Indeed, what I wanted to put inside was an hash of random data.. but a unique and specific data. Commented Feb 19, 2014 at 11:21
-
If it is random unique hash data why not trusting the UUID's own generation of random unique hash data? Otherwise why not using your random hash/data as key and leaving UUID alone? I think I'm not catching fully your intent.– dendiniCommented Feb 19, 2014 at 11:25
-
Because the existing system accepts UUIDs but I want the data to be marked into the UUID. Commented Feb 19, 2014 at 11:29
-
-
In theory inside UUID v3 you should put a URL which is itself unique. Of course you can also put your MD5/SHA hash but I would consider deeply the objections I have made in my answer before taking this path.– dendiniCommented Feb 20, 2014 at 8:30