libuuid
uuid-generate
uuid-generate/  random
uuid-generate/  time
8.18

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)

"6cff215e-1bd2-4602-a659-de1ef57ed78d"

> (uuid-generate)

"12169bac-e73d-433a-8f04-7a63662f80dd"

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)

"53d24c51-f9dc-4e99-97f2-483a9ec1834c"

> (uuid-generate/random)

"4ffcbcc4-4daa-4cf0-8645-07da296e9d6b"

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)

"4087c66a-7bd0-11f0-ad43-1fc229200f80"

> (uuid-generate/time)

"4087df56-7bd0-11f0-ad43-1fc229200f80"