libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.0.0.3

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)

"e7ea0543-f5cc-4c77-a609-f269be8514f0"

> (uuid-generate)

"e5ecb265-b211-4833-a219-81b98d35aefa"

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)

"5adcb32d-95da-4860-8857-5b5e89a595ca"

> (uuid-generate/random)

"03ebf5e7-1002-4077-a940-23b4d7e1492f"

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)

"d91a2d8a-b8ef-11f0-9287-e9d74267d79d"

> (uuid-generate/time)

"d91a763c-b8ef-11f0-9287-e9d74267d79d"