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 🙏

© 2026 – Pkg Stats / Ryan Hefner

env-cryptr

v1.4.0

Published

A tool to encrypt and decrypt environment variables using JWT

Downloads

18

Readme

env-cryptr

A secure command-line tool to encrypt and decrypt environment variables using JWT tokens. Perfect for safely storing sensitive environment variables.

Features

  • 🔒 Encrypts .env files using AES-256-CBC encryption with enhanced security:
    • Random salt generation for each encryption
    • PBKDF2 key derivation (100,000 iterations)
    • HMAC-SHA256 message authentication
    • Unique salt:iv:hmac:ciphertext format
  • 🎯 Uses JWT for secure token management
  • 🚀 Simple CLI interface
  • ⚡ Easy to use with any project
  • 🔑 Secure key management

Installation

You can install the package globally:

npm install -g env-cryptr

Or use it directly with npx:

npx env-cryptr <command>

Usage

As a CLI Tool

Basic Structure

Your .env file must include an ENV_KEY that will be used for encryption/decryption. This key MUST be 32 characters long.

ENV_KEY=this-is-32-characters-secure-key
DATABASE_URL=mongodb://localhost:27017
API_KEY=your-secret-api-key
COMPLEX_VALUE='value with spaces and symbols !@#$%^&*()'

Encrypting .env file

Using flags:

# Print to console
npx env-cryptr -e -i .env.example

# Save to file
npx env-cryptr -e -i .env.example -o .env.encrypted

Using command:

# Print to console
npx env-cryptr encrypt -i .env.example

# Save to file
npx env-cryptr encrypt -i .env.example -o .env.encrypted

Decrypting .env file

Using flags:

# From file, print to console
npx env-cryptr -d -i .env.encrypted

# From file, save to file
npx env-cryptr -d -i .env.encrypted -o .env.decrypted

Using command:

# From file, print to console
npx env-cryptr decrypt -i .env.encrypted

# From file, save to file
npx env-cryptr decrypt -i .env.encrypted -o .env.decrypted

# From token, print to console
npx env-cryptr decrypt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

# From token, save to file
npx env-cryptr decrypt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... -o .env.decrypted

As a Node.js Module

Install the package:

npm install env-cryptr

Import and use in your code:

import EnvCryptr from 'env-cryptr';

// Encrypt environment variables
const env = {
    ENV_KEY: 'this-is-32-characters-secure-key',
    DATABASE_URL: 'mongodb://localhost:27017',
    API_KEY: 'your-secret-api-key'
};

// Create a new instance for encryption
const cryptr = new EnvCryptr();
const token = cryptr.encrypt(env);
console.log('Encrypted token:', token);

// Initialize with an existing token for decryption
const decryptor = new EnvCryptr(token);

// Decrypt specific variables
const dbUrl = decryptor.decrypt('DATABASE_URL');
console.log('Decrypted DATABASE_URL:', dbUrl);

// Get all decrypted values
const allValues = Object.keys(env).reduce((acc, key) => {
    acc[key] = decryptor.decrypt(key);
    return acc;
}, {});
console.log('All decrypted values:', allValues);

Command Options

Encrypt Mode

# Using flags
env-cryptr -e -i <input-file> [-o output-file]

# Using command
env-cryptr encrypt -i <input-file> [-o output-file]

Decrypt Mode

# Using flags with file
env-cryptr -d -i <input-file> [-o output-file]

# Using command with file
env-cryptr decrypt -i <input-file> [-o output-file]

# Using command with token
env-cryptr decrypt <token> [-o output-file]

Error Handling

The tool includes comprehensive error handling for common scenarios:

  • Missing ENV_KEY
  • Wrong length of ENV_KEY (must be 32 characters)
  • Invalid file paths
  • Corrupted encrypted files
  • Invalid JWT tokens
  • Token tampering detection

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © Mohd Khairulnizam

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.