Generate a name-based UUID v5 using SHA-1 hashing of namespace and name.
Code
Utilitiesns=$(echo -n "${namespace//-/}" | sed 's/../\\x&/g')
hash=$(printf "${ns}${name}" | sha1sum | cut -c1-32)
v=$(printf '%x' $(( (0x${hash:12:2} & 0x0f) | 0x50 )))${hash:14:2}
c=$(printf '%x' $(( (0x${hash:16:2} & 0x3f) | 0x80 )))${hash:18:2}
echo "${hash:0:8}-${hash:8:4}-${v}-${c}-${hash:20:12}"Parameters
Namespace UUID (use DNS, URL, OID, or X500 namespace).
Name to hash within the namespace.
Server
More Bash Snippets
Generate UUID v1
Generate a time-based UUID v1 using timestamp and random node ID.
Generate UUID v3
Generate a name-based UUID v3 using MD5 hashing of namespace and name.
Generate UUID v4
Generate a random UUID v4 (Universally Unique Identifier).
Generate UUID v6
Generate a reordered time-based UUID v6 with improved sortability for databases.
Generate UUID v7
Generate a Unix timestamp-based UUID v7 with millisecond precision, ideal for database primary keys.
Array Difference
Find elements in the first array that are not present in the second array.