For some reason, I have to make UUIDs that are same when same strings are input like below.
UUID.nameUUIDFromBytes(str.getBytes());
What I want to know is this new UUID satisfy below conditions.
I checked those in the UUID docs but I want a more confirmation as deployment without those conditions can make our system disaster.
Yes, as defined in the RFC 4122 - 4.3. Algorithm for Creating a Name-Based UUID:
The requirements for these types of UUIDs are as follows:
- The UUIDs generated at different times from the same name in the same namespace MUST be equal.
Yes (and no), as defined in the RFC 4122 - 4.3. Algorithm for Creating a Name-Based UUID:
[...]
The UUIDs generated from two different names in the same namespace should be different (with very high probability).
Practically, different byte arrays results in different UUIDs. But there have been MD5 collisions, therefore the mentioned "with very high probability".
No, the name-based UUID have the version number set to 3
(or 5
), the time based UUID have the version set to 1
.