libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.1.0.9

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)

"a4176ccc-e942-414e-bec2-c52f07fd23fc"

> (uuid-generate)

"d61c39b1-1e42-413a-9b49-d280aa13e46d"

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)

"f1cc8fb2-271b-4d66-9625-0de96f234557"

> (uuid-generate/random)

"32620239-7571-4fa6-b248-ba75085e81fe"

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)

"efb73226-14b2-11f1-a19d-45c64d21604b"

> (uuid-generate/time)

"efb73bf4-14b2-11f1-a19d-45c64d21604b"