Skip to content

hash

bytes_to_hash(data, hash_algorithm='sha256')

Source code in griptape/utils/hash.py
4
5
6
7
8
9
def bytes_to_hash(data: bytes, hash_algorithm: str = "sha256") -> str:
    m = hashlib.new(hash_algorithm)

    m.update(data)

    return m.hexdigest()

str_to_hash(text, hash_algorithm='sha256')

Source code in griptape/utils/hash.py
def str_to_hash(text: str, hash_algorithm: str = "sha256") -> str:
    m = hashlib.new(hash_algorithm)

    m.update(text.encode())

    return m.hexdigest()