CLI utility to encrypt .env files.
  • Rust 94.8%
  • Python 4.2%
  • Shell 1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-20 17:31:43 +01:00
src polish: output just the key on generate 2026-11-20 16:56:41 +01:00
.gitignore docs: add README and license 2026-11-20 17:12:33 +01:00
Cargo.lock feat: add base64 crate 2026-11-15 19:00:31 +01:00
Cargo.toml feat: add base64 crate 2026-11-15 19:00:31 +01:00
end_to_end_test.py polish: fail test on wrong exit codes for subprocesses 2026-11-20 11:35:35 +01:00
env.test test: start testing with more inputs 2026-11-18 23:49:13 +01:00
LICENSE docs: add README and license 2026-11-20 17:12:33 +01:00
README.md docs: remove typo, clarify limits 2026-11-20 17:31:43 +01:00
test_decrypt.sh feat: implement decryption 2026-11-18 23:18:24 +01:00
test_encrypt.sh feat: implement decryption 2026-11-18 23:18:24 +01:00

cryptenv

This is a CLI utility to encrypt and decrypt your .env files so they can be safely committed to VCS repos. It tries to Keep It Simple and adheres to the Unix philosophy: Do one thing, and do it well.

I am a beginner with Rust and still learning. 🦀

In particular:

  • Do not rely on this to keep your AWS secrets safe in a public GitHub repository
  • better: do not use this in production at all

I did not write the actual encryption algorithms used, but there might be fuckups in library usage.

Features

  • encrypt .env files
  • decrypt .env files
  • generate AES keys for later use

Non-Features

  • not a full fledged high-level encryption tool
  • no runtime encryption/decryption on the fly (so decrypted values are visible to anyone on your server)

Usage

Generate an AES key:

cryptenv generate

Uses stdout, so standard Unix CLI is available:

cryptenv generate > key.txt

Encrypt an .env file:

cryptenv encrypt --source-file=env.test --target-file=env.crypt

Encrypt an .env file in-place:

cryptenv encrypt --source-file=env.test # omit target file

Decrypt commands work exactly the same.

All commands expect the MASTER_KEY environment variable to be set to a valid base64-encoded AES key as generated by the generate subcommand.

If none is set, you are prompted to provide one.

Crates used

  • base64 for enconding/decoding byte values
  • aes-gcm for the actual encryption
  • clap for the CLI parsing functionality

=> this is basically all glue code that a LLM could garble out in 5 minutes. I chose not to use one though.

Library Features

In theory, you could use this as a high level layer on top of aes-gcm to encrypt arbitrary strings, but you're probably better off using the mentioned crates directly.

License

Licensed under AGPL-3.

Contributing

Nobody does that these days, who are you kidding?