Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUIDs in a C++ Linux GCC app

Tags:

c++

linux

guid

gcc

I've got a bunch of servers running this Linux app. I'd like for them to be able to generate a GUID with a low probability of collision. I'm sure I could just pull 128 bytes out of /dev/urandom and that would probably be fine, but is there a simple & easy way to generate a GUID that is more equivalent to the Win32 one? Specifically, one that takes into account space (well, MAC address), time, and randomness? I don't want to call off the box for it, I just want something like CreateGuid()

like image 485
twk Avatar asked Sep 30 '08 15:09

twk


2 Answers

This Internet Draft describes one type of UUID in great details and I have used a similar approach with great success when I needed a UUID implementation and could not link to an existing library for architectural reasons.

This article provides a good overview.

like image 151
David Segonds Avatar answered Sep 23 '22 15:09

David Segonds


There is libuuid.

like image 23
zvrba Avatar answered Sep 19 '22 15:09

zvrba