Make the default size for hash_string an option

This commit is contained in:
Grant Sanderson
2024-12-05 11:53:55 -06:00
parent 34ad61d013
commit b593cde317

View File

@ -96,7 +96,6 @@ def binary_search(function: Callable[[float], float],
return mh return mh
def hash_string(string: str) -> str: def hash_string(string: str, n_bytes=16) -> str:
# Truncating at 16 bytes for cleanliness
hasher = hashlib.sha256(string.encode()) hasher = hashlib.sha256(string.encode())
return hasher.hexdigest()[:16] return hasher.hexdigest()[:n_bytes]