Potential fix for code scanning alert no. 15: Use of a broken or weak cryptographic hashing algorithm on sensitive data

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
拾风
2025-11-13 20:54:42 +08:00
committed by Windpicker-owo
parent 44b824a690
commit d63cb41b62

View File

@@ -46,12 +46,12 @@ def generate_cache_key(
if args:
args_str = ",".join(str(arg) for arg in args)
args_hash = hashlib.md5(args_str.encode()).hexdigest()[:8]
args_hash = hashlib.sha256(args_str.encode()).hexdigest()[:8]
cache_key_parts.append(f"args:{args_hash}")
if kwargs:
kwargs_str = ",".join(f"{k}={v}" for k, v in sorted(kwargs.items()))
kwargs_hash = hashlib.md5(kwargs_str.encode()).hexdigest()[:8]
kwargs_hash = hashlib.sha256(kwargs_str.encode()).hexdigest()[:8]
cache_key_parts.append(f"kwargs:{kwargs_hash}")
return ":".join(cache_key_parts)