24 lines
806 B
JavaScript
24 lines
806 B
JavaScript
const crypto = require('crypto');
|
|
|
|
function decode(encryptedData) {
|
|
try {
|
|
const algorithm = 'aes-256-cbc';
|
|
const iv = Buffer.from(encryptedData.slice(0, 24), 'base64');
|
|
const keyHex = 'd0ca711dc0c599de0847cb86f415cd34d602a322f0f07dc89bce9e1481f481b3';
|
|
const derivedKey = Buffer.from(keyHex, 'hex');
|
|
const encryptedText = encryptedData.slice(24);
|
|
|
|
const decipher = crypto.createDecipheriv(algorithm, derivedKey, iv);
|
|
let decrypted = decipher.update(encryptedText, 'base64', 'utf8');
|
|
decrypted += decipher.final('utf8');
|
|
|
|
console.log('Decrypted String:', decrypted);
|
|
return decrypted;
|
|
} catch (error) {
|
|
console.error('Decryption failed:', error.message);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
module.exports = decode;
|