libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
8.17.0.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)

"e6e17a59-bb37-4398-a230-e83dbc3c5ccd"

> (uuid-generate)

"a103326c-d363-437b-b1b0-12414626bf71"

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)

"91b3b22f-217b-4afa-86ac-a2f1c6d613d3"

> (uuid-generate/random)

"2597e3de-7867-4147-b0e0-2b7519aba384"

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)

"f3508778-40d4-11f0-87d7-074b12218d62"

> (uuid-generate/time)

"f350ab18-40d4-11f0-87d7-074b12218d62"