libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
7.4

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)

"43e749fb-7108-47ee-ad84-2341379c9db9"

> (uuid-generate)

"b65a27c4-9313-4e47-8cd8-3404051b2e62"

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)

"21b07408-d5c0-4c2f-8a3d-0f4431401d7e"

> (uuid-generate/random)

"6cfcaaad-03b5-43cf-bbca-db18eac5581b"

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)

"b77e8b4c-c582-11e9-97b6-3f20650b4dbb"

> (uuid-generate/time)

"b77ea33e-c582-11e9-97b6-3f20650b4dbb"