Home / Function/ _apply_hash_strategy() — langchain Function Reference

_apply_hash_strategy() — langchain Function Reference

Architecture documentation for the _apply_hash_strategy() function in _redaction.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  59dbcc65_5bbf_d10e_9919_eaec975a7579["_apply_hash_strategy()"]
  be639235_9a02_cc2d_5a7d_637d822fb3b3["_redaction.py"]
  59dbcc65_5bbf_d10e_9919_eaec975a7579 -->|defined in| be639235_9a02_cc2d_5a7d_637d822fb3b3
  a830b2dc_75ff_a1e7_d25c_7de2223efe55["apply_strategy()"]
  a830b2dc_75ff_a1e7_d25c_7de2223efe55 -->|calls| 59dbcc65_5bbf_d10e_9919_eaec975a7579
  style 59dbcc65_5bbf_d10e_9919_eaec975a7579 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/_redaction.py lines 297–303

def _apply_hash_strategy(content: str, matches: list[PIIMatch]) -> str:
    result = content
    for match in sorted(matches, key=operator.itemgetter("start"), reverse=True):
        digest = hashlib.sha256(match["value"].encode()).hexdigest()[:8]
        replacement = f"<{match['type']}_hash:{digest}>"
        result = result[: match["start"]] + replacement + result[match["end"] :]
    return result

Domain

Subdomains

Called By

Frequently Asked Questions

What does _apply_hash_strategy() do?
_apply_hash_strategy() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py.
Where is _apply_hash_strategy() defined?
_apply_hash_strategy() is defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py at line 297.
What calls _apply_hash_strategy()?
_apply_hash_strategy() is called by 1 function(s): apply_strategy.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free