Function: uuid-v4

uuid-v4 is a byte-compiled function defined in uuid.el.gz.

Signature

(uuid-v4 &key RNG)

Documentation

Return a new UUIDv4 ID.

RNG is an alternate random number function which should take a single argument, the limit (exclusive) for the random number, and return an integer between 0 and that number. To be valid according to RFC 9562, the random numbers should be cryptographically secure, which the default random number generator typically is not, so if these UUIDs are important, it's advised to use a better random number function, which typically requires getting random numbers from outside of Emacs.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/uuid.el.gz
(cl-defun uuid-v4 (&key rng)
  "Return a new UUIDv4 ID.

RNG is an alternate random number function which should take a single
argument, the limit (exclusive) for the random number, and return an
integer between 0 and that number.  To be valid according to RFC 9562,
the random numbers should be cryptographically secure, which the default
random number generator typically is not, so if these UUIDs are
important, it's advised to use a better random number function, which
typically requires getting random numbers from outside of Emacs."
  (uuid--from-parts (uuid--random-bits 48 rng)
                    (uuid--random-bits 12 rng)
                    (uuid--random-bits 62 rng)
                    4 2))