def short_str(s, length=8) -> str:
    """
    Returns a hashed string, somewhat similar to URL shortener.
    """
    hash_str = hashlib.sha256(s.encode()).hexdigest()
    return hash_str[0:length]
Returns a hashed string, somewhat similar to URL shortener.
python/aitemplate/utils/misc.py