sealed-env (Library)
Small helper library that reads encrypted environment variables from the
process environment and decrypts them using SEALED_KEY.
Install
Add to Cargo.toml:
= "0.1"
Behavior
- Reads from process environment.
- Encrypted values must start with
ENCv1:. - Uses
SEALED_KEYfrom the environment to decrypt. - Returns UTF-8 plaintext on success.
API
sealed_env::var(name)- Strict: requires the variable to be present and encrypted.
sealed_env::var_or_plain(name)- Lenient: returns plaintext as-is if the value is not encrypted.
sealed_env::var_optional(name)- Optional: returns
Ok(None)if the variable is not set; otherwise decrypts if needed.
- Optional: returns
Examples
use ;
set_var;
set_var;
let secret = var?;
let plain = var_or_plain?;
let maybe = var_optional?;
# Ok::
Errors
MissingVar: requested variable is not set.MissingKey:SEALED_KEYis not set.NotEncrypted: value is not prefixed withENCv1:.Crypto: base64 or decryption errors.