Function: uuid-v5
uuid-v5 is a byte-compiled function defined in uuid.el.gz.
Signature
(uuid-v5 NAMESPACE NAME)
Documentation
Return a new UUIDv5 ID from the given NAMESPACE and NAME.
NAMESPACE should be a symbol corresponding to a namespace in
uuid-namespace-alist. If this is not recognized it will signal an
uuid-invalid-namespace signal.
NAME is the name from which to generate the UUID, and should be a string.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/uuid.el.gz
(defun uuid-v5 (namespace name)
"Return a new UUIDv5 ID from the given NAMESPACE and NAME.
NAMESPACE should be a symbol corresponding to a namespace in
`uuid-namespace-alist'. If this is not recognized it will signal an
`uuid-invalid-namespace' signal.
NAME is the name from which to generate the UUID, and should be a
string."
(let* ((namespace-uuid (or
(alist-get namespace uuid-namespace-alist)
(signal 'uuid-invalid-namespace (list namespace))))
(hash-bytes (sha1
(concat
(uuid-to-bytes namespace-uuid)
(encode-coding-string name 'utf-8))
nil nil t))
(hash-vals (bindat-unpack uuid--bindat-type hash-bytes)))
(uuid--from-parts (assoc-default :high hash-vals)
(uuid--lower-bits (assoc-default :ver-mid hash-vals) 12)
(uuid--lower-bits (assoc-default :var-low hash-vals) 62)
5 2)))