libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
7.2

libuuid

Jan Dvorak <[email protected]>

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)

"ba2b3d6e-204b-48a9-b017-1b4acdd93f2d"

> (uuid-generate)

"18f9d8c7-a805-4f30-b8e8-6f826e2adb40"

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)

"ee7f91ee-3ceb-4b09-924b-9363977d405e"

> (uuid-generate/random)

"31676bb7-2221-4939-ad87-1db156c08a50"

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)

"38e0c188-255f-11e9-93ff-1daa9cfbe6c6"

> (uuid-generate/time)

"38e0cd9a-255f-11e9-93ff-1daa9cfbe6c6"