use anyhow::Result; use cipherstash_client::{ config::{ console_config::ConsoleConfig, cts_config::CtsConfig, zero_kms_config::ZeroKMSConfig, }, zerokms::EncryptPayload, }; use clap::Parser; #[derive(Parser, Debug)] #[command(version)] struct Args { #[arg(long)] descriptor: String, #[arg(long)] message: String, } #[tokio::main] async fn main() -> Result<()> { let args = Args::parse(); let console_config = ConsoleConfig::builder().with_env().build()?; let cts_config = CtsConfig::builder().with_env().build()?; let zero_kms_config = ZeroKMSConfig::builder() .console_config(&console_config) .cts_config(&cts_config) .with_env() .build_with_client_key()?; let zero_kms = zero_kms_config.create_client(); let record = zero_kms .encrypt_single( EncryptPayload { msg: args.message.as_bytes(), descriptor: &args.descriptor, }, None, ) .await?; println!("ZeroKMS: {}", zero_kms_config.base_url()); println!("Workspace: {}", zero_kms_config.base_url()); println!("Message: {}", args.message); println!("Descriptor: {}", args.descriptor); println!("---"); // Encode using MessagePack and Base85 println!("Encrypted: {}", record.to_mp_base85()?); Ok(()) }