decrypt

Decrypt an encrypted value with a private key

Rust primitives

dotenvx_primitives::decrypt

Usage

Decrypts a recognized Dotenvx ciphertext with its matching private key. Plain values are returned unchanged. Errors expose stable codes through Error::code().


let pair = dotenvx_primitives::keypair(None)?;
let ciphertext = dotenvx_primitives::encrypt(&pair.public_key, "World")?;
let value = dotenvx_primitives::decrypt(&pair.private_key, &ciphertext)?;
assert_eq!(value, "World");

markdown