Created
November 23, 2021 10:59
-
-
Save pierremonico/f5b93546bf0ac35b067738c62067aa0e to your computer and use it in GitHub Desktop.
Helper function to generate a deterministic UUID from a list of strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import hashlib | |
def uuid_from_strings(*args: str) -> str: | |
"""Generates a deterministic UUID when given n strings.""" | |
seed = "".join(args) | |
m = hashlib.md5() | |
m.update(seed.encode("utf-8")) | |
return str(uuid.UUID(m.hexdigest())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment