I am wondering if there is a way to generate the same UUID based on a String.
I tried with UUID, it looks like it does not provide this feature.
The fromString() method of UUID class in Java is used for the creation of UUID from the standard string representation of the same. Parameters: The method takes one parameter UUID_name which is the string representation of the UUID. Return Value: The method returns the actual UUID created from the specified string.
From the documentation and wikipedia we see that randomUUID is good - but there is a very small chance that duplicates can be generated.
This also means that one can (in theory) guarantee that some two inputs out there can wind up with the same UUID, and as a result, UUIDs are not generally reversible (however, in specific (limited) cases, perhaps they could be made reversible).
You can use UUID this way to get always the same UUID for your input String:
String aString="JUST_A_TEST_STRING"; String result = UUID.nameUUIDFromBytes(aString.getBytes()).toString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With