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

pandoras-bx

v0.0.1

Published

pandro-bx is a versatile encryption library for JavaScript and TypeScript that provides time-based encryption, cursed encryption, and simple encryption functionalities.

Downloads

5

Readme

pandro-bx

pandro-bx is a versatile encryption library for JavaScript and TypeScript that provides time-based encryption, cursed encryption, and simple encryption functionalities. It ensures secure data handling with AES-256-CBC encryption and offers features such as time-based access restrictions and custom error handling.

Installation

You can install the package via npm:

npm install pandro-bx

Usage

JavaScript

Here's an example of how to use the pandro-bx package in a JavaScript project:

const { TimeCapsule, Cursed, Treasure } = require('pandro-bx');
const crypto = require('crypto');

// TimeCapsule Example
const plaintextTime = 'Hello, World!';
const keyTime = crypto.randomBytes(32);
const unlockDateTimeStr = '21-06-2024 15:53'; // DD-MM-YYYY HH:mm format
const userProvidedIvTime = crypto.randomBytes(16);

const encryptedTime = TimeCapsule.hibernate(
  plaintextTime,
  keyTime,
  unlockDateTimeStr,
  userProvidedIvTime
);
console.log('TimeCapsule - Encrypted data:', encryptedTime);

setTimeout(() => {
  try {
    const decryptedTime = TimeCapsule.arise(encryptedTime, keyTime);
    console.log('TimeCapsule - Decrypted data:', decryptedTime);
  } catch (error) {
    console.error('TimeCapsule - Error:', error.message);
  }
}, 70000); // Wait for 70 seconds before attempting to decrypt

// Cursed Example
const plaintextCursed = 'Hello, World!';
const keyCursed = crypto.randomBytes(32);
const unlockDateTimeStrCursed = '21-06-2024 15:53'; // DD-MM-YYYY HH:mm format
const userProvidedIvCursed = crypto.randomBytes(16);

const encryptedCursed = Cursed.whisper(
  plaintextCursed,
  keyCursed,
  unlockDateTimeStrCursed,
  userProvidedIvCursed,
  true // Curse enabled
);
console.log('Cursed - Encrypted data:', encryptedCursed);

setTimeout(() => {
  try {
    const decryptedCursed = Cursed.peek(encryptedCursed, keyCursed);
    console.log('Cursed - Decrypted data:', decryptedCursed);
  } catch (error) {
    console.error('Cursed - Error:', error.message);
  }
}, 70000); // Wait for 70 seconds before attempting to decrypt

// Treasure Example
const plaintextTreasure = 'Hello, World!';
const keyTreasure = crypto.randomBytes(32);

const encryptedTreasure = Treasure.bury(plaintextTreasure, keyTreasure);
console.log('Treasure - Encrypted data:', encryptedTreasure);

try {
  const decryptedTreasure = Treasure.dig(encryptedTreasure, keyTreasure);
  console.log('Treasure - Decrypted data:', decryptedTreasure);
} catch (error) {
  console.error('Treasure - Error:', error.message);
}

TypeScript

For TypeScript users, you can directly import the modules and use them with type safety:

import { TimeCapsule, Cursed, Treasure } from 'pandro-bx';
import * as crypto from 'crypto';

// TimeCapsule Example
const plaintextTime: string = 'Hello, World!';
const keyTime: Buffer = crypto.randomBytes(32);
const unlockDateTimeStr: string = '21-06-2024 15:53'; // DD-MM-YYYY HH:mm format
const userProvidedIvTime: Buffer = crypto.randomBytes(16);

const encryptedTime: string = TimeCapsule.hibernate(
  plaintextTime,
  keyTime,
  unlockDateTimeStr,
  userProvidedIvTime
);
console.log('TimeCapsule - Encrypted data:', encryptedTime);

setTimeout(() => {
  try {
    const decryptedTime: string = TimeCapsule.arise(encryptedTime, keyTime);
    console.log('TimeCapsule - Decrypted data:', decryptedTime);
  } catch (error: any) {
    console.error('TimeCapsule - Error:', error.message);
  }
}, 70000); // Wait for 70 seconds before attempting to decrypt

// Cursed Example
const plaintextCursed: string = 'Hello, World!';
const keyCursed: Buffer = crypto.randomBytes(32);
const unlockDateTimeStrCursed: string = '21-06-2024 15:53'; // DD-MM-YYYY HH:mm format
const userProvidedIvCursed: Buffer = crypto.randomBytes(16);

const encryptedCursed: string = Cursed.whisper(
  plaintextCursed,
  keyCursed,
  unlockDateTimeStrCursed,
  userProvidedIvCursed,
  true // Curse enabled
);
console.log('Cursed - Encrypted data:', encryptedCursed);

setTimeout(() => {
  try {
    const decryptedCursed: string = Cursed.peek(encryptedCursed, keyCursed);
    console.log('Cursed - Decrypted data:', decryptedCursed);
  } catch (error: any) {
    console.error('Cursed - Error:', error.message);
  }
}, 70000); // Wait for 70 seconds before attempting to decrypt

// Treasure Example
const plaintextTreasure: string = 'Hello, World!';
const keyTreasure: Buffer = crypto.randomBytes(32);

const encryptedTreasure: string = Treasure.bury(plaintextTreasure, keyTreasure);
console.log('Treasure - Encrypted data:', encryptedTreasure);

try {
  const decryptedTreasure: string = Treasure.dig(
    encryptedTreasure,
    keyTreasure
  );
  console.log('Treasure - Decrypted data:', decryptedTreasure);
} catch (error: any) {
  console.error('Treasure - Error:', error.message);
}

Modules

TimeCapsule

Provides time-based encryption and decryption.

Methods

  • hibernate(data: string, key: Buffer, unlockDateTimeStr: string, iv1?: Buffer): string

    • Encrypts data with a specified unlock date-time.
    • data: The plaintext data to encrypt.
    • key: The encryption key (32 bytes for AES-256).
    • unlockDateTimeStr: The unlock date-time in 'DD-MM-YYYY HH:mm' format.
    • iv1: Optional initialization vector (IV).
  • arise(encryptedData: string, key: Buffer): string

    • Decrypts data if the current time is past the unlock date-time.
    • encryptedData: The encrypted data.
    • key: The encryption key.

Cursed

Provides time-based encryption with a curse option that triggers an action if decryption is attempted before the unlock time.

Methods

  • whisper(data: string, key: Buffer, unlockDateTimeStr: string, iv1?: Buffer, curse?: boolean): string

    • Encrypts data with a specified unlock date-time and optional curse.
    • data: The plaintext data to encrypt.
    • key: The encryption key (32 bytes for AES-256).
    • unlockDateTimeStr: The unlock date-time in 'DD-MM-YYYY HH:mm' format.
    • iv1: Optional initialization vector (IV).
    • curse: Optional boolean to enable the curse feature.
  • peek(encryptedData: string, key: Buffer): string

    • Decrypts data if the current time is past the unlock date-time; triggers curse if enabled.
    • encryptedData: The encrypted data.
    • key: The encryption key.

Treasure

Provides simple encryption and decryption without time-based restrictions.

Methods

  • bury(data: string, key: Buffer): string

    • Encrypts data.
    • data: The plaintext data to encrypt.
    • key: The encryption key (32 bytes for AES-256).
  • dig(encryptedData: string, key: Buffer): string

    • Decrypts data.
    • encryptedData: The encrypted data.
    • key: The encryption key.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.