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

@edirect/encrypt-modules

v11.0.54

Published

Encrypt Modules

Readme

@edirect/encrypt-modules

Encryption utilities for eDirect NestJS applications. Provides four NestJS modules for different encryption algorithms: PGP, Binary PGP, AES-256, and RSA — plus a ZIP module for password-protected archive creation.

Features

  • PGP encryption/decryption using OpenPGP.js (openpgp)
  • Binary PGP for binary data encryption
  • AES-256-CBC (and other AES variants) using Node.js native crypto
  • RSA encryption/decryption using node-rsa
  • ZIP password-protected archive creation
  • NestJS module integration for each encryption type

Installation

pnpm add @edirect/encrypt-modules
# or
npm install @edirect/encrypt-modules

Available Modules

PGP Encryption (PgpEncryptModule)

Asymmetric encryption using OpenPGP keys:

import { Module } from '@nestjs/common';
import { PgpEncryptModule } from '@edirect/encrypt-modules';

@Module({
  imports: [PgpEncryptModule],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { PgpEncryptService } from '@edirect/encrypt-modules';

@Injectable()
export class SecureDataService {
  constructor(private readonly pgp: PgpEncryptService) {}

  async encryptPayload(data: string, publicKey: string): Promise<string> {
    return this.pgp.encrypt(publicKey, data);
  }

  async decryptPayload(
    encryptedData: string,
    privateKey: string,
    passphrase?: string
  ): Promise<string> {
    return this.pgp.decrypt(privateKey, encryptedData, passphrase);
  }
}

PgpEncryptService API:

| Method | Signature | Description | | --------- | ------------------------------------------------------------------------------- | ------------------------------------ | | encrypt | (pgpKey: string, dataToEncrypt: string): Promise<string> | Encrypt data using a PGP public key | | decrypt | (pgpKey: string, encryptedData: string, passphrase?: string): Promise<string> | Decrypt data using a PGP private key |

AES Encryption (AesEncryptModule)

Symmetric encryption using Node.js crypto:

import { AesEncryptModule } from '@edirect/encrypt-modules';

@Module({ imports: [AesEncryptModule] })
export class AppModule {}
import { AesEncryptService } from '@edirect/encrypt-modules';

// Default: AES-256-CBC
const encrypted = aesService.encrypt(
  'secret data',
  'my-32-char-passphrase-here!!!!!'
);
const decrypted = aesService.decrypt(
  encrypted,
  'my-32-char-passphrase-here!!!!!'
);

// With custom IV and encoding
const encrypted2 = aesService.encrypt('data', passphrase, {
  iv: customIv,
  encryptionMethod: 'aes-256-cbc',
  outputEncoding: 'base64',
});

AesEncryptService API:

| Method | Signature | Description | | --------- | ----------------------------------------------------------------------------------------------------- | -------------------------- | | encrypt | (message: string, passphrase: CipherKey, options?: IaesEncryptOptionalParameters): string | Synchronous AES encryption | | decrypt | (encryptedMessage: string, passphrase: BinaryLike, options?: IaesDecryptOptionalParameters): string | Synchronous AES decryption |

RSA Encryption (RsaEncryptModule)

Asymmetric encryption using node-rsa:

import { RsaEncryptModule } from '@edirect/encrypt-modules';

@Module({ imports: [RsaEncryptModule] })
export class AppModule {}
import { RsaEncryptService } from '@edirect/encrypt-modules';

const encrypted = rsaService.encrypt(data, 512, 'utf8');
const decrypted = rsaService.decrypt(encrypted, privateKey, 'utf8');

ZIP with Password (ZipEncryptModule)

Create password-protected ZIP archives:

import { ZipEncryptModule } from '@edirect/encrypt-modules';

@Module({ imports: [ZipEncryptModule] })
export class AppModule {}

AES Optional Parameters

| Option | Type | Default | Description | | ------------------ | ------------------ | --------------- | ---------------------------------- | | iv | BinaryLike | Random | Initialization vector | | encryptionMethod | string | 'aes-256-cbc' | Cipher algorithm | | inputEncoding | Encoding | 'utf8' | Input data encoding | | outputEncoding | Encoding | 'hex' | Output encoding for encrypted data | | options | TransformOptions | — | Additional stream options |

Security Notes

  • Never hardcode encryption keys in source code. Use environment variables.
  • For PGP keys, store them in secure secret management (e.g., Kubernetes Secrets, AWS Secrets Manager).
  • AES keys must be exactly 32 bytes for AES-256. Use a key derivation function (KDF) if your passphrase is shorter.