libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
8.16

libuuid🔗

Jan Dvorak <mordae@anilinux.org>

Interface to the libuuid library usable to generate high-quality UUIDs.

 (require libuuid) package: libuuid

procedure

(uuid-generate)  string?

Generate new universally unique identifier using /dev/urandom, if available. If it is not available, use current time, local ethernet MAC address and random data from a pseudo-random generator.

Examples:
> (uuid-generate)

"bd60d5ef-d171-44c1-b137-94d84f8ed6a9"

> (uuid-generate)

"0eee90c3-5a45-412f-9362-9679a6f4e046"

procedure

(uuid-generate/random)  string?

When /dev/urandom is available, same as uuid-generate, but fails back to a pseudo-random generator only.

Can be used to prevent any chance of host’s MAC address leaking, at the cost of slightly higher chance of generating non-unique identifiers if the worst-case situation arises on multiple hosts.

Examples:
> (uuid-generate/random)

"a02918ae-02af-43bf-b441-0ccb322d08e5"

> (uuid-generate/random)

"c37c1492-399c-4d3a-b3b9-685d924c1915"

procedure

(uuid-generate/time)  string?

Same as uuid-generate when the /dev/urandom is missing.

Could potentially produce non-uniqueue identifiers if used concurrently so if you do not absolutely need sequential identifiers, stick with the generic (and safe) uuid-generate function above.

Examples:
> (uuid-generate/time)

"d163e98c-f630-11ef-83a5-2ba583640f6f"

> (uuid-generate/time)

"d163fbe8-f630-11ef-83a5-2ba583640f6f"