The Secure Encryption SDK provides an easy-to-use encryption and decryption system for securely storing and managing user data. This SDK ensures data confidentiality by using a central key, a master key, and automatically rotating user-specific encryption keys.
- Secure Data Encryption: Encrypts user data with unique encryption keys.
- Automatic Key Rotation: Enhances security by periodically rotating encryption keys.
- Master Key Recovery: Allows data recovery in case of lost encryption keys.
- Lightweight & Fast: Optimized for performance and security.
You can install the SDK using npm or yarn:
npm install secure-encryption-sdk
or
yarn add secure-encryption-sdk
const { encryptData, decryptData } = require('secure-encryption-sdk');
const centralKey = process.env.CENTRAL_KEY;
const masterKey = process.env.MASTER_KEY;
const userData = "Sensitive Information";
const { encryptedData, userKey } = encryptData(userData, centralKey, masterKey);
console.log("Encrypted Data:", encryptedData);
console.log("User Key:", userKey);
const decryptedData = decryptData(encryptedData, userKey, centralKey, masterKey);
console.log("Decrypted Data:", decryptedData);
To enhance security, the SDK automatically rotates encryption keys upon decryption:
const { newEncryptedData, newUserKey, decryptedData } = decryptData(encryptedData, userKey, centralKey, masterKey, true);
console.log("New Encrypted Data:", newEncryptedData);
console.log("New User Key:", newUserKey);
console.log("Decrypted Data:", decryptedData);
Ensure you set the following environment variables:
CENTRAL_KEY=<your-central-key>
MASTER_KEY=<your-master-key>
- Store
CENTRAL_KEY
andMASTER_KEY
securely (e.g., in environment variables or a vault). - Rotate keys periodically to maintain security.
- Do not expose user encryption keys in logs or UI.
This SDK is licensed under the MIT License.