can it be reversed? if I use
>>> RESOURCE_ID_NAMESPACE = uuid.UUID('0a7a15ff-aa13-4ac2-897c-9bdf30ce175b')
>>> value = 'test'
>>> uuid.uuid5(RESOURCE_ID_NAMESPACE, value)
UUID('7fd19145-920f-5b9c-be0a-2146b0c39949')
if I know the uuid5 value, can I get the value 'test'?
thanks a lot.
The uuid module provides immutable UUID objects (the UUID class) and the functions uuid1() , uuid3() , uuid4() , uuid5() for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122. If all you want is a unique ID, you should probably call uuid1() or uuid4() .
UUID 1 to Generate a unique ID using MAC Address The uuid. uuid1() function is used to generate a UUID from the host ID, sequence number, and the current time. It uses the MAC address of a host as a source of uniqueness.
uuid5(namespace, string) : This function uses SHA-1 hash value of namespaces mentioned with a string to generate a random id of that particular string.
UUID, Universal Unique Identifier, is a python library which helps in generating random objects of 128 bits as ids.
UUID version 5 is based on the SHA-1 hash of the input. The whole point of cryptographic hashing algorithms is that they're nearly impossible to reverse in the general case.
If you know the input was a dictionary word, sure, you could just generate a uuid5 value for every word in the dictionary, same goes for when you know it's a short string of letters, but in the general case, no, you can't reverse a UUID5 value any more than you can a cryptographic hash. And no, the weaknesses in SHA-1 are unlikely to be helpful here; they're useful largely in generating collisions, but not recovering the original value.
No, you cannot. The uuid is created by hashing the namespace and value you pass into the constructor. But there are an infinite number of other possible strings (although they're probably hard to find) that hash to the same value. So there's no way to determine what the original string was that constructed the uuid.
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