1.0.0 • Published 11 months ago

@mahdi.golzar/encripttool v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

EncryptionTool

EncryptionTool is a simple utility for encrypting and decrypting data using symmetric encryption algorithms. It provides an easy interface to securely encrypt sensitive data and later decrypt it.

Features

  • Symmetric encryption using aes-256-cbc
  • Configurable encryption algorithm
  • Secure key generation using scryptSync
  • Easy to use and integrate into Node.js applications

Installation

This project relies on Node.js's built-in crypto module and does not require any external dependencies.

Usage

  1. Copy the Code First, save the following code in a file named encryptionTool.js:
// Example usage

const encryptionTool = new EncryptionTool('aes-256-cbc', 'your-password-here');

const dataToEncrypt = "This is some data that needs encryption!";
const encryptedData = encryptionTool.encrypt(dataToEncrypt);
console.log("Encrypted:", encryptedData);

const decryptedData = encryptionTool.decrypt(encryptedData);
console.log("Decrypted:", decryptedData);
  1. Run the Script To run the script and see the encryption and decryption in action, execute the following command in your terminal:
node encryptionTool.js

You should see the encrypted and decrypted output in your console.

Adding New Algorithms

You can specify different symmetric encryption algorithms supported by Node.js's crypto module by passing the desired algorithm name to the EncryptionTool constructor.

Example:

const encryptionTool = new EncryptionTool('aes-192-cbc', 'your-password-here');

Method Descriptions

encrypt(text): Encrypts the given text using the configured algorithm and key, returning the IV and encrypted text as a single string. decrypt(encryptedText): Decrypts the given encrypted text back to its original form using the stored key and algorithm.

1.0.0

11 months ago