LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdkencryptiontypesJsonEncryptor
    Attribute●Since v0.2

    JsonEncryptor

    Copy
    JsonEncryptor = Callable[[EncryptionContext, Json], Awaitable[Json]]
    View source on GitHub

    Parameters

    NameTypeDescription
    ctx*unknown

    Encryption context with model type, field name, and metadata

    data*unknown

    The plaintext JSON dictionary

    Handler for encrypting structured JSON data.

    Note: Must be an async function. Encryption typically involves I/O operations (calling external KMS services), which should be async.

    Used for encrypting structured data like metadata, context, kwargs, values, and other JSON-serializable fields across different model types.

    Maps plaintext fields to encrypted fields. A practical approach:

    • Keep "owner" field unencrypted for search/filtering
    • Encrypt VALUES (not keys) for fields with specific prefix (e.g., "my.customer.org/")
    • Pass through all other fields unencrypted

    Example:

    Input: {"owner": "user123", "my.customer.org/email": "john@example.com", "tenant_id": "t-456"} Output: {"owner": "user123", "my.customer.org/email": "ENCRYPTED", "tenant_id": "t-456"}

    Note: Encrypted field VALUES cannot be reliably searched, as most real-world encryption implementations use nonces (non-deterministic encryption). Only unencrypted fields can be used in search queries.