npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

envcryptor

v1.0.3

Published

A simple CLI tool to encrypt and decrypt environment variables

Downloads

3

Readme

EnvCryptor

EnvCryptor is a lightweight tool designed to help teams securely share environment variables by encrypting and decrypting .env files. This ensures that sensitive information can be managed safely across different environments.

Features

🔒 Encrypt: Securely encrypt environment variable files. 🔓 Decrypt: Decrypt environment variable files back to plaintext. 🖋️ Edit: Edit encrypted environment variable files securely. 🔑 Generate Key: Generate new encryption keys for secure operations. 💨 Run: Execute commands with environment variables decrypted on-the-fly. 🪶 Lightweight: Minimal dependencies and easy to integrate into any project.

Installation

You can install the package using npm:

npm install envcryptor

Or install it globally:

npm install -g envcryptor

Usage

Encrypt

Encrypt an environment variable file using an encryption key:

Using a key as a string:

npx envcryptor encrypt <input> <output> -s <encryption_key>

Using a key from a .key file:

npx envcryptor encrypt <input> <output> -f <key_file>

Options:

  • <input>: Path to the input .env file.
  • <output>: Path to the output encrypted file.
  • -s <encryption_key>: Encryption key as a string.
  • -f <key_file>: Path to the encryption key file.

Decrypt

Decrypt an encrypted environment variable file:

Using a key as a string:

npx envcryptor decrypt <input> <output> -s <encryption_key>

Using a key from a .key file:

npx envcryptor decrypt <input> <output> -f <key_file>

Options:

  • <input>: Path to the input encrypted file.
  • <output>: Path to the output decrypted .env file.
  • -s <encryption_key>: Encryption key as a string.
  • -f <key_file>: Path to the encryption key file.

Edit

Edit an encrypted environment variable file:

Using a key as a string:

npx envcryptor edit <file> -s <encryption_key>

Using a key from a .key file:

npx envcryptor edit <file> -f <key_file>

Options:

  • <file>: Path to the encrypted .env file.
  • -s <encryption_key>: Encryption key as a string.
  • -f <key_file>: Path to the encryption key file.

Generate Key

Generate a new encryption key and either save it to a file or output it to the console:

To save to a .key file:

npx envcryptor keygen -o <output>

To output to the console:

npx envcryptor keygen

Options:

  • -o <output>: Path to the output .key file.

Run

Run a command with decrypted environment variables:

Using a key as a string:

npx envcryptor run <file> -s <encryption_key> -- <command>

Using a key from a .key file:

npx envcryptor run <file> -f <key_file> -- <command>

Options:

  • <file>: Path to the encrypted .env file.
  • -f <key_file>: Path to the encryption key file.
  • -s <encryption_key>: Encryption key as a string.
  • <command>: Command to run with decrypted environment variables.

Examples

Encrypt an environment variable file:

npx envcryptor encrypt .env .env.enc -s my_secret_key

Decrypt an encrypted environment variable file:

npx envcryptor decrypt .env.enc .env -s my_secret_key

Edit an encrypted environment variable file:

npx envcryptor edit .env.enc -s my_secret_key

Generate a new encryption key:

npx envcryptor keygen -o .env.key

Run a command with decrypted environment variables:

npx envcryptor run .env.enc -f .env.key -- node index.js

Load Environment Variables

You can also load environment variables from an encrypted file directly into your application using the loadEnv function:

import loadEnv from "envcryptor/loadEnv";

loadEnv({
	path: ".env.enc",
	key: "path/to/your/key.key",
});

// Your environment variables are now loaded into process.env
console.log(process.env.YOUR_VARIABLE);

Contributing

We welcome contributions! Feel free to submit issues, fork the repository, and send pull requests.

License

This project is licensed under the MIT License.


This README provides an overview of how to use the EnvCryptor package to manage and securely share environment variables within your team. For more detailed information, refer to the specific function documentation and examples provided in the sections above.