libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.3.0.8

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)

"e2dba6fd-0871-4528-a96c-ee31ecce3a6a"

> (uuid-generate)

"158d4556-79d1-4c61-a89a-98381dd5da40"

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)

"aa09126d-14c7-420f-b3c5-df4b18ea2b6a"

> (uuid-generate/random)

"bc937f5f-5428-4be3-af90-bc0891b771eb"

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)

"4ba77f3c-b83c-11f1-94f5-f3151be6e0bd"

> (uuid-generate/time)

"4ba79346-b83c-11f1-94f5-f3151be6e0bd"