Drop-in replacement for env!
that encrypts your variables at compile-time and decrypts them at runtime,
preventing naughty folks from snooping your binary for secrets or credentials.
```rust use envcrypt::envcrypt;
fn main() { let mysupersecretkey = envcrypt!("SECRETKEY"); // do stuff with your secret key } ```
With dotenv
:
.env
:
dotenv
CLIENT_SECRET="my_client_secret"
SOME_TOKEN="some_token"
build.rs
:
```rust fn main() { println!("cargo:rerun-if-changed=.env");
for (key, value) in dotenv::vars() { println!("cargo:rustc-env=${key}=${value}"); } } ```
main.rs
:
```rust use envcrypt::envcrypt;
fn main() { let clientsecret = envcrypt!("CLIENTSECRET"); } ```
Encryption is powered by MagicCrypt
using AES-256 encryption.