A secure AES-256-GCM encryption/decryption library using Argon2 password hashing.
✅ Uses AES-256-GCM (high security)
✅ Password-based key derivation using Argon2id
✅ Uses random salts & IVs for stronger encryption
✅ Easy to use & lightweight
Install via npm:
npm install cryptoswiftjs
Or with yarn:
yarn add cryptoswiftjs
const { encrypt } = require('cryptoswiftjs');
const message = "Hello, Secure World!";
const password = "mySuperStrongPassword123";
(async () => {
const encrypted = await encrypt(message, password);
console.log("Encrypted:", encrypted);
})();
const { decrypt } = require('cryptoswiftjs');
(async () => {
const encryptedData = "your_encrypted_data_here";
const decrypted = await decrypt(encryptedData, "mySuperStrongPassword123");
console.log("Decrypted:", decrypted);
})();
-
Password-Based Key Derivation
- Uses Argon2id to generate a 32-byte key from the password.
- Includes random salts for enhanced security.
-
AES-256-GCM Encryption
- Encrypts data with a random IV using AES-256-GCM.
- Generates an authentication tag to prevent tampering.
-
Secure Decryption
- Uses the same password to derive the key and decrypt the data.
- Validates the authentication tag to ensure integrity.
- Never reuse salts & IVs for the same password.
- Do not hardcode passwords in your application.
- Use a strong password (long, random, and unique).
- Consider additional encryption layers for highly sensitive data.
Encrypts the given text using AES-256-GCM and returns an encrypted string.
Decrypts the encrypted string back to its original plaintext.
For bug reports or feature requests, visit:
🔗 GitHub Issues
- Fork the repository
- Create a new branch (
git checkout -b feature-branch
) - Commit your changes (
git commit -m "Added a cool feature"
) - Push the branch (
git push origin feature-branch
) - Submit a pull request 🚀
Licensed under the MIT License.
💡 Made with ❤️ by Suvojit Modak