const crypto = require('crypto'); function encode(inputString) { try { const algorithm = 'aes-256-cbc'; const iv = crypto.randomBytes(16); const keyHex = 'd0ca711dc0c599de0847cb86f415cd34d602a322f0f07dc89bce9e1481f481b3'; const derivedKey = Buffer.from(keyHex, 'hex'); const cipher = crypto.createCipheriv(algorithm, derivedKey, iv); let encrypted = cipher.update(inputString, 'utf8', 'base64'); encrypted += cipher.final('base64'); const encryptedData = iv.toString('base64') + encrypted; console.log('Encrypted String:', encryptedData); return encryptedData; } catch (error) { console.error('Encryption failed:', error.message); return null; } } module.exports = encode;