Isaac Mateus
Isaac Mateus

Reputation: 21

Is it possible to get name or namespace from UUID V5?

Is it possible to decode the namespace or the name from a given UUID?

Imagine that you have a house with a specific UUID and code, and now you need to know if the door or the windows belongs to the house only by looking at UUIDs.

My idea is to somehow put the house code inside the window and door UUID. and then somehow checking if the generated ids belong to the house extracting the house code inside from them.

Upvotes: 2

Views: 1906

Answers (1)

Stephen C
Stephen C

Reputation: 718658

Is it possible to get name or namespace from UUID V5?

No. It is not possible to extract either the name or namespace from a type 3 or type 5 UUID.

These two UUID types are produced by using MD5 or SHA1 to generate a 128 or 160 bit hash from a string that combines the name and namespace. Then some bits of the hash are thrown away.

It is mathematically impossible to reverse a hashing function (because of the Pigeonhole Principle) so extracting the original name or namespace would be impossible, even if the UUID contained the complete hash.

See also:

which says:

"Version-3 and version-5 UUIDs have the property that the same namespace and name will map to the same UUID. However, neither the namespace nor name can be determined from the UUID, even if one of them is specified, except by brute-force search. RFC 4122 recommends version 5 (SHA-1) over version 3 (MD5), and warns against use of UUIDs of either version as security credentials."

(Even then, the brute force search approach will only tell you that the name / namespace that you haverecovered could be the one used to create the UUID.)


If you wanted to encode the the UUID and code of a house (or whatever) in an identifier, then you would need to use a reversible transformation on some representation of the information; e.g. Base64 encoding (insecure) or public key or private key encryption (potentially secure).

Upvotes: 3

Related Questions