import crypto from 'crypto'; const algorithm = 'aes-256-ctr'; const secretKey = process.env.SECRET_KEY; export const encrypt = (text) => { const cipher = crypto.createCipheriv(algorithm, secretKey, Buffer.alloc(16, 0)); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); return encrypted.toString('hex'); }; export const decrypt = (hash) => { const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.alloc(16, 0)); const decrpyted = Buffer.concat([decipher.update(Buffer.from(hash, 'hex')), decipher.final()]); return decrpyted.toString(); };