UNPKG

user-key-crypto

Version:

A simple and secure Node.js library to encrypt and decrypt data using user-defined secret keys. Perfect for privacy-focused applications.

65 lines (44 loc) โ€ข 1.33 kB
# user-key-crypto ๐Ÿ” A simple and secure Node.js library to encrypt and decrypt data using **user-defined secret keys**. Perfect for applications where **privacy and user-level encryption** is critical. ## ๐Ÿš€ Installation ```bash npm install user-key-crypto ``` ## ๐Ÿ“ฆ Usage ```js const { encrypt, decrypt } = require('user-key-crypto'); // Encrypt and decrypt const encrypted = encrypt('Secret Info','mySecretKey##45'); console.log('Encrypted:', encrypted); const decrypted = decrypt(encrypted,'mySecretKey##45'); console.log('Decrypted:', decrypted); ``` ## โš ๏ธ Error Handling ```js const { encrypt } = require('user-key-crypto'); try { const encrypted = encrypt('data',688); // Throws error if key is not string } catch (err) { console.error(err.message); // Secret must be a string } ``` ## ๐Ÿงช Run Tests ```bash npm test ``` ## โœจ Features - AES-256-GCM encryption - PBKDF2 key derivation - Random salt, IV, and auth tag - Stateless utility functions - Fully error-handled ## ๐Ÿ”’ Use Cases - End-to-end encrypted messaging - User-level encryption in databases - Secure configuration handling ## ๐Ÿ› ๏ธ Tech Used - crypto (Native Node.js) ## ๐Ÿ“„ License MIT ## ๐Ÿ‘จโ€๐Ÿ’ป Author [Abdul Wahab](https://github.com/Abdul-Wahab-Abbasi) โ€ข [LinkedIn](https://linkedin.com/in/web-crafter)