Skip to content

Instantly share code, notes, and snippets.

@pierremonico
Created November 23, 2021 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pierremonico/f5b93546bf0ac35b067738c62067aa0e to your computer and use it in GitHub Desktop.
Save pierremonico/f5b93546bf0ac35b067738c62067aa0e to your computer and use it in GitHub Desktop.
Helper function to generate a deterministic UUID from a list of strings
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