Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tiktoken/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ def read_file_cached(blobpath: str, expected_hash: str | None = None) -> bytes:
# disable caching
return read_file(blobpath)

cache_key = hashlib.sha1(blobpath.encode()).hexdigest()
# cache_key = hashlib.sha1(blobpath.encode()).hexdigest()
# Replaced SHA-1 with SHA-256 to avoid security scanner flags.
# Not used for crypto purposes, but aligns with current best practices.

cache_key = hashlib.sha256(blobpath.encode()).hexdigest()


cache_path = os.path.join(cache_dir, cache_key)
if os.path.exists(cache_path):
Expand Down