I have a simple C ++ function that calls uuid_generate_random. The generated UUID does not seem to be standard (UUID Version 4). Any ideas?
The code I use (uuid_generate_random and uuid_unparse functions are available in libuuid):
char uuidBuff[36]; uuid_t uuidGenerated; uuid_generate_random(uuidGenerated); uuid_unparse(uuidGenerated, uuidBuff);
I understand that "uuid_generate_random" generates a version of UUID 4, however the returned string looks like this:
Run1) 2e9dc3c5-426a-eea0-8186-f6b65b5dc361 Run2) 112c6a78-51bc-cbbb-ae9c-92a33e1fd95f Run3) 5abd3d6d-0259-ce5c-8428-a51bacc04c0f Run4) 66a22485-7e5f-e5c2-a317-c1b295bf124f
It looks like it returns random characters for the entire string. The definition from Wikipedia should be in the form:
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx with hexadecimal digits for x, but only one of 8, 9, A or B for y.
Any input is appreciated.
Relationship Daniel
source share