libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.3.0.2

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)

"e10a5e55-cc6f-43e6-9734-75c0c085de6f"

> (uuid-generate)

"eb3e1c9c-fadc-4807-8754-924f45237442"

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)

"b3cf2027-9eb5-4206-b542-cdf1515403cf"

> (uuid-generate/random)

"562c3ac0-f805-47f5-b3b5-8b3156c838ee"

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)

"692b333a-8170-11f1-bafb-a7b2a47d4699"

> (uuid-generate/time)

"692b70ca-8170-11f1-bafb-a7b2a47d4699"