@despair56434/encryption
v1.0.4
Published
`@despair56434/encryption` is a Node.js module that provides utility functions for encryption and decryption using the AES-256-GCM algorithm. It includes functions to generate cryptographic keys and initialization vectors (IVs), as well as to encrypt and
Downloads
350
Readme
Description
@despair56434/encryption
is a Node.js module that provides utility functions for encryption and decryption using the AES-256-GCM algorithm. It includes functions to generate cryptographic keys and initialization vectors (IVs), as well as to encrypt and decrypt data.
Installation
To install this package, use npm:
npm install @despair56434/encryption
Usage
Importing the Module
import {
decryptData,
encryptData,
generateIV,
generateKey,
} from "@despair56434/encryption";
Generating a Key
const password = "password";
const salt = "salt";
const iterations = 1000; // random number you will implement in your application
const key = generateKey(password, salt, iterations);
Generating an Initialization Vector (IV)
const IV = generateIV();
Encrypting Data
const data = {
name: "username",
surname: "surname",
age: 24,
email: "[email protected]",
};
const encryptedData = encryptData(key, IV, JSON.stringify(data));
Decrypting Data
const decryptedData = decryptData(key, encryptedData);
Changelog
1.0.4
- Improved Error Handling
- Improved types
1.0.3
- Updated encryptData and decryptData functions to handle the authentication tag properly.
- Ensured that the IV and auth tag are prepended to the encrypted data and correctly extracted during decryption.