Encrypt
Synopsis
Encrypts string values using AES encryption with optional compression. Supports both AES-256-GCM (Galois/Counter Mode) and AES-256-CFB (Cipher Feedback) modes of operation.
Schema
encrypt:
- algorithm: <string>
- encryption_key: <string>
- field: <ident>
- iv_field: <ident>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- on_failure: <processor[]>
- on_success: <processor[]>
- tag: <string>
- with_compression: <boolean>
Configuration
Field | Required | Default | Description |
---|---|---|---|
algorithm | N | AES-256-GCM | Encryption algorithm. Valid values: AES-256-GCM or AES-256-CFB |
encryption_key | Y | - | 32-byte key for encryption |
field | Y | - | Field containing the value to encrypt |
iv_field | Y | - | Field to store the initialization vector |
description | N | - | Explanatory note |
if | N | - | Conditional expression |
ignore_failure | N | false | Continue if encryption fails |
ignore_missing | N | false | Continue if source field is missing |
on_failure | N | - | Processors to run on failure |
on_success | N | - | Processors to run on success |
tag | N | - | Identifier for logging |
with_compression | N | false | Compress data before encryption |
Details
The processor encrypts string values using AES encryption, with support for two encryption modes:
Encryption Modes
- AES-256-GCM (Recommended):
- Provides confidentiality and authenticity
- More secure against tampering
- Slightly slower performance
- AES-256-CFB:
- Provides confidentiality
- Faster performance
- No built-in authentication
Compression
When with_compression
is enabled:
- Data is compressed before encryption
- Reduces encrypted data size
- Most effective for text-based data
- Minimal impact on already compressed content
Security Recommendations
Key Management
- Use cryptographically secure random number generators
- Implement regular key rotation (every 90 days)
- Store keys securely using:
- Key Management Services (KMS)
- Hardware Security Modules (HSM)
- Follow principle of least privilege
Initialization Vector (IV) Management
- Generate using cryptographically secure random number generator
- Never reuse IVs with the same key
- Recommended IV sizes:
- GCM mode: 12 bytes (96 bits)
- CFB mode: 16 bytes (128 bits)
Secure Storage
- Store encrypted data and IVs separately from encryption keys
- Use filesystem-level encryption
- Implement secure backup procedures
- Use authenticated encryption (GCM mode)
Examples
Basic Encryption
Encrypt a sensitive field using GCM mode... |
|
creates encrypted output: |
|
Compression with Encryption
Compress and encrypt large text data... |
|
reduces encrypted data size: |
|
Error Handling
Handle missing or invalid fields... |
|
continues processing with error handling: |
|
note
- Encryption keys are cached for performance
- Compression is most effective for text-based data
- Use environment variables or secure key management for encryption keys
warning
- Use exactly 32-byte encryption keys
- Never reuse initialization vectors
- Protect encryption keys rigorously
- Be aware of performance overhead