Generate a UUID from the MD5 hash of a namespace UUID and a name.
(namespace, name)
| 762 | clock_seq_hi_variant, clock_seq_low, node), version=1) |
| 763 | |
| 764 | def uuid3(namespace, name): |
| 765 | """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" |
| 766 | if isinstance(name, str): |
| 767 | name = bytes(name, "utf-8") |
| 768 | import hashlib |
| 769 | h = hashlib.md5(namespace.bytes + name, usedforsecurity=False) |
| 770 | int_uuid_3 = int.from_bytes(h.digest()) |
| 771 | int_uuid_3 &= _RFC_4122_CLEARFLAGS_MASK |
| 772 | int_uuid_3 |= _RFC_4122_VERSION_3_FLAGS |
| 773 | return UUID._from_int(int_uuid_3) |
| 774 | |
| 775 | def uuid4(): |
| 776 | """Generate a random UUID.""" |