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

sensitive-file-manager

v1.0.1

Published

A simple package to manage sensitive files

Readme

sensitive-file-manager

sensitive-file-manager is a sleek, lightweight, and open-source Node.js package designed to safeguard your sensitive configuration or data files using robust AES-256-CBC encryption. Crafted with ES6 modules and async/await, it offers a modern, intuitive API for seamless file-based encryption and decryption.

🌟 Features

  • File-Based Encryption: Encrypt and decrypt files effortlessly by specifying source and destination paths. The module reads the file, encrypts its contents with a randomly generated Initialization Vector (IV), and prepends the IV to the ciphertext for hassle-free decryption.

  • Secure Key Generation: Use the static method generateSecretKey() to generate a secure, random 32-byte key (returned as a 64-character hex string) for encrypting/decrypting your files. Store this key safely in an environment variable.

  • Easy Integration: With a straightforward API, you can integrate file encryption into your projects without diving into low-level crypto logic.

  • Modern & Lightweight: Written in TypeScript using ES6 modules and async/await, it leverages Node's built-in crypto and fs modules, minimizing external dependencies.

🛠️ Installation

Install the package via npm:

npm install sensitive-file-manager

🚀 Usage

Basic Example

import { SensitiveFileManager } from 'sensitive-file-manager';

// Generate a new secret key and store it in an environment variable for later use
const newKey = SensitiveFileManager.generateSecretKey();
console.log('Generated Secret Key:', newKey);

// Retrieve the secret key from an environment variable
const secretKey = process.env.SECRET_KEY;
if (!secretKey) {
    throw new Error(
        'Secret key not provided in environment variable SECRET_KEY'
    );
}

// Create an instance with the secret key
const manager = new SensitiveFileManager(secretKey);

// Encrypt a file from "sensitive-data.json" to "encrypted-data.enc"
await manager.encryptFile('sensitive-data.json', 'encrypted-data.enc');
console.log('File encrypted successfully.');

// Decrypt the file "encrypted-data.enc" and get its content as a Buffer
const decryptedData = await manager.decryptFile('encrypted-data.enc');
console.log('Decrypted file content:', decryptedData.toString('utf8'));

API Overview

  • Constructor new SensitiveFileManager(secretKeyHex: string) Pass a 64-character hex string (32 bytes) as your secret key.

  • encryptFile(srcPath: string, destPath: string): Promise Reads the file at srcPath, encrypts its contents, and writes the IV-prepended ciphertext to destPath.

  • decryptFile(srcPath: string): Promise Reads the encrypted file at srcPath, extracts the IV, decrypts the data, and returns it as a Buffer.

  • static generateSecretKey(): string Generates a secure random secret key (32 bytes) and returns it as a 64-character hex string.

🔒 Unique Benefits & Example Scenarios

  • Enhanced Security for Configuration Files: Encrypt your accounts data or configuration files (e.g., FTP/SFTP settings) to ensure that even if the file is exposed, its content remains secure. Decryption requires the secret key, which can be stored in an environment variable.

  • Multi-Account Management: Manage multiple sensitive accounts with a single encrypted file containing all configurations. Your application decrypts it at runtime, ensuring sensitive details are never stored in plain text.

  • Seamless Integration: Unlike other packages that focus solely on encrypting strings or buffers, sensitive-file-manager provides a file-centric API that fits naturally into applications working with file-based configurations.

📜 License

MIT

🤝 Open Source

sensitive-file-manager is proudly open source! We welcome contributions from the community to help improve and expand the functionality of this package.