![]() ![]() Now you can have calls: uuid = NameToUUID(Namespace_DNS, 'uuid = NameToUUID(Namespace_DNS, 'uuid = NameToUUID(Namespace_URL, '') įor version 3 and version 5 UUIDs the additional command line arguments namespace and name have to be given. (Note: the endian-ness of your system can affect indices of the above bytes) set high-nibble to 5 to indicate type 5 Copy first 16-bytes of the hash into our Uuid result Note: All code on stackoverflow is public domain - no attribution required.īyte hash = sha1(NamespaceUUID.ToBytes() + Name.ToBytes()) Now that you have a function that generates a so-called Name, you can have the function (in pseudo-code): UUID NameToUUID(UUID NamespaceUUID, String Name) The basic gist is to only take the first 128 bits, stuff a 5 in the type record, and then set the first two bits of the clock_seq_hi_and_reserved section to 1 and 0, respectively. StackOverflowUrlUUID = sha1(Namespace_URL + "") ![]() So, you could hash together: StackOverflowDnsUUID = sha1(Namespace_DNS + "") ![]() The UUID RFC pre-defines four namespaces for you: You prefix your string with a so-called namespace to prevent name conflicts. You're probably wondering what is it that I'm supposed to hash. ╰─low nibble is set to 5, to indicate type 5 ⭡ ⬑first two bits set to 1 and 0, respectively Type 6: unofficial idea for sequential UUIDsĮdit: Unofficial type 6 now has an official rfcĪn SHA1 hash outputs 160 bits (20 bytes) the result of the hash is converted into a UUID.Type 5: stuffs an SHA1 hash into 128 bits.Type 4: stuffs random data into 128 bits.Type 3: stuffs an MD5 hash into 128 bits.Type 1: stuffs MAC address+ datetime into 128 bits.Type 3 and Type 5 UUIDs are just a technique of stuffing a hash into a UUID: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |