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

"79dec5d4-f3ff-436b-b1ca-08175a5c3cbd"

> (uuid-generate)

"660b9290-20bd-4564-9d4c-e34a27103197"

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)

"4c30eb4d-09fb-48ae-a6cd-d322f3622147"

> (uuid-generate/random)

"ef26352c-22f4-4877-8396-78ea0d813c1b"

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)

"20be403a-85f6-11f1-bf92-396e77859d23"

> (uuid-generate/time)

"20be499a-85f6-11f1-bf92-396e77859d23"