Cipherion
Sdk IntegrationsPython SDK

Configuration

Configure the Cipherion client for your needs

Sync vs Async Client

Cipherion provides both synchronous and asynchronous Python clients.

ClientUse Case
CipherionClientStandard scripts, Django, Flask, blocking environments
AsyncCipherionClientFastAPI, async applications, high concurrency

The asynchronous client works the same way as the synchronous client, but its methods must be used with await. Calling these methods without await will return a coroutine object instead of the actual result.

Learn how to configure the Cipherion client with various options.

Basic Configuration

Synchronous

import os
from cipherion import CipherionClient

client = CipherionClient({
    "base_url": os.getenv("CIPHERION_BASE_URL"),
    "project_id": os.getenv("CIPHERION_PROJECT_ID"),
    "api_key": os.getenv("CIPHERION_API_KEY"),
    "passphrase": os.getenv("CIPHERION_PASSPHRASE"),
    "timeout": 30000,
    "retries": 3,
    "log_level": "info",
    "enable_logging": True
})

Asynchronous

import os
from cipherion import AsyncCipherionClient

client = AsyncCipherionClient({
    "base_url": os.getenv("CIPHERION_BASE_URL"),
    "project_id": os.getenv("CIPHERION_PROJECT_ID"),
    "api_key": os.getenv("CIPHERION_API_KEY"),
    "passphrase": os.getenv("CIPHERION_PASSPHRASE"),
    "timeout": 30000,
    "retries": 3,
    "log_level": "info",
    "enable_logging": True
})

Configuration Options

Required Options

OptionTypeDescription
baseUrlstringAPI base URL (e.g., https:api.cipherion.in)
projectIdstringYour project identifier from Cipherion dashboard
apiKeystringAPI authentication key
passphrasestringEncryption passphrase (minimum 12 characters)

Optional Options

OptionTypeDefaultDescription
timeoutnumber30000Request timeout in milliseconds
retriesnumber3Maximum retry attempts for failed requests
logLevelstring'info'Log level: 'error', 'warn', 'info', 'debug'
enableLoggingbooleantrueEnable/disable logging

Environment Variables

Using environment variables is the recommended approach:

.env
CIPHERION_BASE_URL=https://api.cipherion.in
CIPHERION_PROJECT_ID=proj_abc123xyz
CIPHERION_API_KEY=sk_live_abc123xyz
CIPHERION_PASSPHRASE=MySecurePassphrase123!
# Configuration loaded from environment variables
client = CipherionClient()

Configuration by Environment

Development

client = CipherionClient(
    "base_url": os.getenv("DEV_CIPHERION_BASE_URL"),
    "project_id": os.getenv("DEV_PROJECT_ID"),
    "api_key": os.getenv("DEV_API_KEY"),
    "passphrase": os.getenv("DEV_PASSPHRASE"),
    "log_level": "debug",
    "enable_logging": True,
    "timeout": 60000
)

Production

client = CipherionClient(
    "base_url": os.getenv("CIPHERION_BASE_URL"),
    "project_id": os.getenv("CIPHERION_PROJECT_ID"),
    "api_key": os.getenv("CIPHERION_API_KEY"),
    "passphrase": os.getenv("CIPHERION_PASSPHRASE"),
    "log_level": "error",
    "enable_logging": True,
    "timeout": 30000,
    "retries": 5
)

Runtime Configuration Updates

You can update non-sensitive configuration at runtime:

# Get current configuration (without sensitive data)
config = client.get_config()
print(config)

# Update configuration
client.update_config({
    "timeout": 60000,
    "log_level": "debug",
    "enable_logging": False
})

You cannot update apiKey or passphrase after initialization. Create a new client instance instead.

Logging Configuration

Log Levels

  • error: Only errors
  • warn: Warnings and errors
  • info: General information (recommended for production)
  • debug: Detailed debugging information (development only)

Example

client = CipherionClient({
    "log_level": "error" if os.getenv("NODE_ENV") == "production" else "debug",
    "enable_logging": True
}
)

Disable Logging

client = CipherionClient({
    "enable_logging": False
    }
)

Passphrase Requirements

Your passphrase must meet these requirements:

  • Minimum 12 characters
  • Mix of uppercase and lowercase letters recommended
  • Include numbers and special characters recommended
# ✅ Good
passphrase: "MySecure#Passphrase2024!"

# ❌ Bad - too short
passphrase: "password"

# ❌ Bad - too weak
passphrase: "123456789012"

Configuration Validation

The SDK validates configuration on initialization:

try:
    client = CipherionClient({
        "passphrase": "short"  # Less than 12 characters
        }
    )
except CipherionError as error:
    print("Invalid configuration:", str(error))
    # "Passphrase must be at least 12 characters long"

Best Practices

  1. Never hardcode credentials
    # ❌ Bad
    client = CipherionClient({
        "api_key": "sk-123456",
        "passphrase": "mysecret"
        }
    )

    # ✅ Good
    client = CipherionClient()
  1. Use different credentials per environment
    credentials = {
        "development": {
            "api_key": os.getenv("DEV_API_KEY"),
            "passphrase": os.getenv("DEV_PASSPHRASE"),
        },
        "production": {
            "api_key": os.getenv("PROD_API_KEY"),
            "passphrase": os.getenv("PROD_PASSPHRASE"),
        },
}
  1. Store passphrases securely
    • Use secret management services (AWS Secrets Manager, HashiCorp Vault)
    • Never commit passphrases to version control
    • Rotate passphrases regularly

On this page