1.0.9 • Published 4 months ago

cryptoswiftjs v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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

  1. Password-Based Key Derivation

    • Uses Argon2id to generate a 32-byte key from the password.
    • Includes random salts for enhanced security.
  2. AES-256-GCM Encryption

    • Encrypts data with a random IV using AES-256-GCM.
    • Generates an authentication tag to prevent tampering.
  3. 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

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -m "Added a cool feature")
  4. Push the branch (git push origin feature-branch)
  5. Submit a pull request šŸš€

šŸ“œ License

Licensed under the MIT License.


šŸ’” Made with ā¤ļø by Suvojit Modak


1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago