libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
9.3.0.10

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)

"cc297e8f-091a-449e-ba24-e923c9d8cd7a"

> (uuid-generate)

"ff2f7b72-525e-4f96-80f7-068b146ea71b"

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)

"2f863dc4-0413-4600-90b0-3eb2c85eb785"

> (uuid-generate/random)

"4590c4ec-a4a9-468a-904a-cf1edbe9db83"

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)

"ab8e9a78-c04a-11f1-8f65-93144ea54e24"

> (uuid-generate/time)

"ab8ea19e-c04a-11f1-8f65-93144ea54e24"