Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def index():

By default the `default_key_builder` builtin key builder is used; this creates a
cache key from the function module and name, and the positional and keyword
arguments converted to their `repr()` representations, encoded as a MD5 hash.
arguments converted to their `repr()` representations, encoded as a BLAKE2 hash.
You can provide your own by passing a key builder in to `@cache()`, or to
`FastAPICache.init()` to apply globally.

Expand Down
1 change: 1 addition & 0 deletions changelog.d/264.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use BLAKE2 instead of MD5.
2 changes: 1 addition & 1 deletion fastapi_cache/key_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def default_key_builder(
args: Tuple[Any, ...],
kwargs: Dict[str, Any],
) -> str:
cache_key = hashlib.md5( # noqa: S324
cache_key = hashlib.blake2b(
f"{func.__module__}:{func.__name__}:{args}:{kwargs}".encode()
).hexdigest()
return f"{namespace}:{cache_key}"