libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
8.17.0.3

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)

"d7bcfa18-3c4b-4221-ba35-1237031f52f7"

> (uuid-generate)

"a56d8082-53d1-4a5c-86e5-e9fc4e686160"

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)

"0ac93b32-616d-4aa1-9f21-e5eaebaa94e6"

> (uuid-generate/random)

"b1a6b042-d203-404a-9e52-c64d4b796e65"

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)

"ee7afc5a-3cc5-11f0-a2f6-f122119a4eff"

> (uuid-generate/time)

"ee7b275c-3cc5-11f0-a2f6-f122119a4eff"