encryption-toolkit
v1.0.2
Published
Encryption library
Downloads
4
Readme
Encryption Toolkit
The Encryption Toolkit is a Node.js library that provides functions for encrypting and decrypting text using the AES-256 encryption algorithm with a secret key.
Installation
You can install the Encryption Toolkit library using npm:
npm install encryption-toolkit
Usage
const { encrypt, decrypt } = require('encryption-toolkit');
const secretKey = 'my_secret_key'; const plainText = 'Hello, World!';
const encryptedData = encrypt(plainText, secretKey); console.log('Encrypted:', encryptedData);
const decryptedText = decrypt(encryptedData, secretKey); console.log('Decrypted:', decryptedText);
API
encrypt(text, secretKey)
Encrypts the provided text using the specified secretKey.
text (string): The plaintext to encrypt.
secretKey (string): The secret key used for encryption.
Returns the encrypted data as a hexadecimal string.
decrypt(encryptedData, secretKey)
Decrypts the provided encryptedData using the specified secretKey.
encryptedData (string): The encrypted data to decrypt.
secretKey (string): The secret key used for decryption.
Returns the decrypted plaintext as a string.
Security Considerations
Ensure that you use a strong and unique secret key for each encryption operation to maintain the security of your encrypted data. Handle and store secret keys securely, following best practices. Consider using additional security measures, such as authentication and access controls, in your application.