Skip to content

jihyunlab/secret

Repository files navigation

@jihyunlab/secret

Version Downloads Last commit License Linter code style: prettier
Build Lint codecov

@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.

Installation

npm i @jihyunlab/secret

Usage

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);

Encryption 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);

Credits

Authored and maintained by JihyunLab <[email protected]>

License

Open source licensed as MIT.