libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.3.900

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)

"f4d466ac-9b0c-49a0-9cec-d628bb6f896e"

> (uuid-generate)

"9d5848f3-7076-4617-b330-d85e61815934"

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)

"276e9fee-b346-4c2d-8fc0-041be2f5b851"

> (uuid-generate/random)

"b7af44d5-d3cf-4b5a-96f8-aee940086a6c"

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)

"b0feda4c-ef5a-11f1-8f28-079794a4905a"

> (uuid-generate/time)

"b0ff193a-ef5a-11f1-8f28-079794a4905a"