pd_cipher::config
Configuration and builder patterns for cipher operations. Unified configuration system for PD.Cipher operations.
This module provides a single source of truth for all configuration options, replacing the scattered configuration approach with a clean, validated, and ergonomic system.
Structs
CipherConfig
Unified configuration for PD.Cipher operations.
CipherConfig provides a single, validated configuration object that
encompasses all aspects of cipher operations including key derivation,
performance settings, and validation parameters.
Examples
Basic Usage
use pd_cipher::config::CipherConfig;
use pd_cipher::EncryptionAlgorithm;
let config = CipherConfig::builder()
.algorithm(EncryptionAlgorithm::Aes256Gcm)
.kdf_iterations(800_000)
.build()
.expect("Valid configuration");
Advanced Configuration
use pd_cipher::config::CipherConfig;
use pd_cipher::EncryptionAlgorithm;
let config = CipherConfig::builder()
.algorithm(EncryptionAlgorithm::XChaCha20Poly1305)
.kdf_iterations(1_000_000)
.enable_parallelism(true)
.max_token_count(500_000)
.with_progress_callback(|current, total| {
println!("Progress: {}/{}", current, total);
})
.build()
.expect("Valid configuration");
Machine Learning Configuration
use pd_cipher::config::{CipherConfig, TextOutputStrategy, NumericOutputStrategy};
// Configure for ML: encrypt schema but keep numbers plain for computation
let ml_config = CipherConfig::builder()
.text_output(TextOutputStrategy::Variable) // Encrypt column names
.numeric_output(NumericOutputStrategy::Plain) // Keep numbers plain
.build()
.expect("Valid ML configuration");
pub struct CipherConfig
Enums
TextOutputStrategy
Output strategy for text tokens.
Controls how text tokens are formatted in the output. This includes whether to encrypt them and, if encrypted, how to format the width.
pub enum TextOutputStrategy {
Plain,
Variable,
FixedShortest,
FixedNextPowerOfTwo,
FixedExact,
FullHash,
}
NumericOutputStrategy
Output strategy for numeric tokens.
Controls how numeric tokens are formatted in the output.
pub enum NumericOutputStrategy {
Plain,
FixedHex16,
}