Encryption Decryption
Easily encrypt and decrypt data with secure, hassle-free functions. Whether you're protecting sensitive information or just hiding your secret taco recipe, we've got you covered!
See it in Action 👇🏻
Follow below steps 👇🏻
Secret Key
Copy a secret key using the button below and store it in your .env file or somewhere safe.
Encryption / Decryption Handlers
Secure your data with ease using the functions below. Simply copy and paste them into your code to encrypt sensitive information and decrypt it when needed. No hassle, just seamless security!
1import crypto from 'crypto';23const IV_LENGTH = 16;45const CRYPTO_SECRET = <YOUR SECRET KEY>; // Replace with your own secret key67// * Encrypt the payload8const encryptData = (payload) => {9const iv = crypto.randomBytes(IV_LENGTH);10const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(CRYPTO_SECRET, 'base64'), iv);1112let encrypted = cipher.update(JSON.stringify(payload), 'utf8', 'base64');13encrypted += cipher.final('base64');1415return { encryptedData: encrypted, iv: iv.toString('base64') };16};1718// * Decrypt the payload19const decryptData = (encryptedData, iv) => {20const decipher = crypto.createDecipheriv(21'aes-256-cbc',22Buffer.from(CRYPTO_SECRET, 'base64'),23Buffer.from(iv, 'base64')24);2526let decrypted = decipher.update(encryptedData, 'base64', 'utf8');27decrypted += decipher.final('utf8');2829return JSON.parse(decrypted);30};
⭐️ Got a question or feedback?
Feel free to reach out!