libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.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)

"8473b702-df1f-43d0-a465-bc041080cc71"

> (uuid-generate)

"cbe3a579-78e1-43cc-a50d-95c6ee7f4ae5"

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)

"8bc7695d-2b3f-4fd7-aa3d-53ebfece76e6"

> (uuid-generate/random)

"dca3715c-5f0c-4ed0-8f60-0dc8456ce48e"

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)

"2f822508-9651-11f1-b0ca-c7db92f4031b"

> (uuid-generate/time)

"2f82418c-9651-11f1-b0ca-c7db92f4031b"