@jihyunlab/secret provides functionality in Node.js applications to decrypt .env files encrypted with @jihyunlab/secret-cli.
The encryption function is implemented with @jihyunlab/crypto and provides encryption for AES 256 GCM.
npm i @jihyunlab/secret
Decrypt the .env key value by directly entering the separately managed encryption key.
import { CIPHER, Env } from '@jihyunlab/secret';
const cipher = await Env.createCipher(CIPHER.AES_256_GCM, 'YourSecretKey');
const value = await cipher.decrypt(process.env.ENV_KEY);
If you register JIHYUNLAB_SECRET_KEY in system or user environment variables, it will be used as the encryption key during encryption.
export JIHYUNLAB_SECRET_KEY=YourSecretKey
You can decrypt the .env key value using the encryption key registered in the environment variables.
import { Env } from '@jihyunlab/secret';
const cipher = await Env.createCipher();
const value = await cipher.decrypt(process.env.ENV_KEY);
Authored and maintained by JihyunLab <[email protected]>
Open source licensed as MIT.