Skip to content

ontocast.text_utils

render_text_hash(text, digits=12)

Generate a hash for the given text.

Parameters:

Name Type Description Default
text str

The text to hash

required
digits

Number of digits in the hash (default: 12)

12

Returns:

Type Description
str

A string hash of the text

Source code in ontocast/text_utils.py
def render_text_hash(text: str, digits=12) -> str:
    """
    Generate a hash for the given text.

    Args:
        text: The text to hash
        digits: Number of digits in the hash (default: 12)

    Returns:
        A string hash of the text
    """
    return hashlib.sha256(text.encode()).hexdigest()[:digits]