1.0.9 ⢠Published 4 months ago
cryptoswiftjs v1.0.9
CryptoSwiftJS š
A secure AES-256-GCM encryption/decryption library using Argon2 password hashing.
š Features
ā
Uses AES-256-GCM (high security)
ā
Password-based key derivation using Argon2id
ā
Uses random salts & IVs for stronger encryption
ā
Easy to use & lightweight
š Installation
Install via npm:
npm install cryptoswiftjs
Or with yarn:
yarn add cryptoswiftjs
š§ Usage
Encrypt Data
const { encrypt } = require('cryptoswiftjs');
const message = "Hello, Secure World!";
const password = "mySuperStrongPassword123";
(async () => {
const encrypted = await encrypt(message, password);
console.log("Encrypted:", encrypted);
})();
Decrypt Data
const { decrypt } = require('cryptoswiftjs');
(async () => {
const encryptedData = "your_encrypted_data_here";
const decrypted = await decrypt(encryptedData, "mySuperStrongPassword123");
console.log("Decrypted:", decrypted);
})();
š ļø How It Works
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.
š„ Security Considerations
- 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.
š API Reference
encrypt(text: string, password: string) => Promise<string>
Encrypts the given text using AES-256-GCM and returns an encrypted string.
decrypt(encryptedData: string, password: string) => Promise<string>
Decrypts the encrypted string back to its original plaintext.
š ļø Issues & Enhancements
For bug reports or feature requests, visit:
š GitHub Issues
š¤ Contributing
- 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 š
š License
Licensed under the MIT License.
š” Made with ā¤ļø by Suvojit Modak