Skip to content

Instantly share code, notes, and snippets.

@bsesic
Last active April 18, 2024 19:39

Revisions

  1. bsesic revised this gist Apr 18, 2024. No changes.
  2. bsesic renamed this gist Mar 13, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion generate_hash_from_UUID.py → generate_hash_UUID.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    def generate_hash_from_UUID(name):
    def generate_hash_UUID(name):
    """
    Generate a UUID based on the hashed string
    Args: name (str): Name of the entity.
  3. bsesic renamed this gist Mar 13, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. bsesic created this gist Mar 13, 2024.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    def generate_hash_from_UUID(name):
    """
    Generate a UUID based on the hashed string
    Args: name (str): Name of the entity.
    Returns: str: UUID of the entity.
    """
    # Hash the string using a hashing algorithm (e.g., SHA-256)
    hashed_string = hashlib.sha256(name.encode()).hexdigest()
    # Generate a UUID based on the hashed string
    uuid_from_hash = uuid.uuid5(uuid.NAMESPACE_OID, hashed_string)
    return uuid_from_hash