@mahdi.golzar/encripttool
Version:
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.
46 lines (36 loc) • 1.83 kB
Markdown
# 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:
```javascript
// 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);
```
2. Run the Script
To run the script and see the encryption and decryption in action, execute the following command in your terminal:
```bash
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:
```javascript
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.