_warn_about_sha1_encoder() — langchain Function Reference
Architecture documentation for the _warn_about_sha1_encoder() function in cache.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2f5d18b0_8768_802d_369c_3d55a4392881["_warn_about_sha1_encoder()"] 43da8c3d_b3f8_9614_dc29_d2a6402cffbd["cache.py"] 2f5d18b0_8768_802d_369c_3d55a4392881 -->|defined in| 43da8c3d_b3f8_9614_dc29_d2a6402cffbd 4b1f75e8_3a36_4d2e_f5d9_04dbd0255a60["_make_default_key_encoder()"] 4b1f75e8_3a36_4d2e_f5d9_04dbd0255a60 -->|calls| 2f5d18b0_8768_802d_369c_3d55a4392881 style 2f5d18b0_8768_802d_369c_3d55a4392881 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/embeddings/cache.py lines 90–105
def _warn_about_sha1_encoder() -> None:
"""Emit a one-time warning about SHA-1 collision weaknesses."""
global _warned_about_sha1 # noqa: PLW0603
if not _warned_about_sha1:
warnings.warn(
"Using default key encoder: SHA-1 is *not* collision-resistant. "
"While acceptable for most cache scenarios, a motivated attacker "
"can craft two different payloads that map to the same cache key. "
"If that risk matters in your environment, supply a stronger "
"encoder (e.g. SHA-256 or BLAKE2) via the `key_encoder` argument. "
"If you change the key encoder, consider also creating a new cache, "
"to avoid (the potential for) collisions with existing keys.",
category=UserWarning,
stacklevel=2,
)
_warned_about_sha1 = True
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _warn_about_sha1_encoder() do?
_warn_about_sha1_encoder() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/embeddings/cache.py.
Where is _warn_about_sha1_encoder() defined?
_warn_about_sha1_encoder() is defined in libs/langchain/langchain_classic/embeddings/cache.py at line 90.
What calls _warn_about_sha1_encoder()?
_warn_about_sha1_encoder() is called by 1 function(s): _make_default_key_encoder.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free