How the encryption works
- A random 16-byte salt and 12-byte IV are generated with
crypto.getRandomValues. - The passphrase is stretched into a 256-bit key with PBKDF2-HMAC-SHA256, 600,000 iterations and the salt.
- The .env text is encrypted with AES-256-GCM, which appends a 16-byte authentication tag.
- Output:
ENVTOOLS:v2:+ base64url(salt ‖ IV ‖ ciphertext ‖ tag), one line of text.
| Format | KDF | Iterations | Status |
|---|---|---|---|
ENVTOOLS:v2: | PBKDF2-SHA256 | 600,000 | current, created by this page |
ENVTOOLS:v1: | PBKDF2-SHA256 | 210,000 | older blobs, still decrypted |
Decrypting without this website
The format uses only standard primitives, so you are never locked in. This Node.js script (no dependencies) decrypts both versions:
// usage: ENVTOOLS_PASSPHRASE='…' node decrypt-envtools.mjs secret.txt > .env
import { readFileSync } from "node:fs";
import { pbkdf2Sync, createDecipheriv } from "node:crypto";
const blob = readFileSync(process.argv[2], "utf8").trim();
const [, version, data] = blob.match(/^ENVTOOLS:(v1|v2):(.+)$/) ?? [];
if (!data) throw new Error("not an ENVTOOLS blob");
const buf = Buffer.from(data, "base64url");
const salt = buf.subarray(0, 16), iv = buf.subarray(16, 28);
const tag = buf.subarray(buf.length - 16), ct = buf.subarray(28, buf.length - 16);
const iterations = version === "v2" ? 600_000 : 210_000;
const key = pbkdf2Sync(process.env.ENVTOOLS_PASSPHRASE, salt, iterations, 32, "sha256");
const d = createDecipheriv("aes-256-gcm", key, iv);
d.setAuthTag(tag);
process.stdout.write(Buffer.concat([d.update(ct), d.final()]).toString("utf8"));Passing the passphrase through an environment variable keeps it out of your shell history (prefix the command with a space in bash/zsh with HISTCONTROL=ignorespace).
Other ways to encrypt .env files
| Tool | How it works | Good for |
|---|---|---|
| This page | passphrase, one blob | one-off sharing, no install |
| SOPS + age | encrypts values in place, keys per recipient | committing encrypted .env files to git |
| dotenvx | encrypted .env with a private key per environment | teams that want encrypted files in the repo |
| age / gpg | encrypt any file to a recipient's public key | sharing without a shared passphrase |
| Secrets manager (Vault, Doppler, Infisical, AWS/GCP) | central store, access control, audit, rotation | teams and production |
The comparison dotenv vs secrets manager explains when a .env file stops being enough. Before encrypting, run the file through the ENV leak checker to see which values are real secrets.