libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.1.0.12

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)

"5ad022a2-82fc-4178-9124-cd210d5b3671"

> (uuid-generate)

"7ce54a8d-3502-425c-b2fc-578fbda9d34d"

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)

"b7ca3a3b-55ca-4267-a986-463800397a1a"

> (uuid-generate/random)

"3084671c-ab7e-4b10-a689-e734830717d1"

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)

"92a04c68-2dca-11f1-ac08-3510ac2c8956"

> (uuid-generate/time)

"92a053c0-2dca-11f1-ac08-3510ac2c8956"