Re: How to create an UUID (Version 1)

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...

Linux: datetime+mac = fine, purely random = not really, needs an option

Yeah the problem is that libuuid doesn't seem to be installed by default on common distros, at least not in my initial testing on Ubuntu and Fedora.

petelomax said...

It should, imo, be new_guid(bool bAllowRand=false) and return (say) {} when uuid_generate=-1 and bAllowRand is false.

According to the documentation, uuid_generate is going to create a random UUID by default:

The uuid_generate function creates a new universally unique identifier (UUID). The uuid will be generated
based on high-quality randomness from /dev/urandom, if available. If it is not available, then
uuid_generate will use an alternative algorithm which uses the current time, the local ethernet MAC
address (if available), and random data generated using a pseudo-random generator.

In that case, I could follow the same method: read bytes from /dev/urandom if I can, otherwise generate it based on the current time, MAC address, and rand().

petelomax said...

Personally, I think that "new()" sucks, what is wrong with "new_guid()"??

I'd prefer to keep it "UUID" since that is the term used by the system libraries. "GUID" is the Microsoft-specific term.

Do we want to just use the libuuid names? uuid_generate, uuid_parse, uuid_unparse (or maybe uuid_format?)

irv said...

Because of the way Eu handles namespaces, I too would prefer that no more "new" keywords were added. Seems better (and causes less namespace clashes) if functions get a more descriptive name.

I was unaware anyone felt this way. I will change it though. I'm indifferent and I can see what you mean.

Side topic: should we be making an effort to roll back the heavy namespace usage?

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu