import crypto from 'crypto';
/**
* Decrypts a value using AES decryption
* @param {string} value - The encrypted value (base64 encoded)
* @returns {string} The decrypted value or empty string if decryption fails
*/
export function decrypt(value) {
const asevkry = "QpqpUVcZd+dYeuyvDa/N2iEb9qZoUBLWimYJorfWmdU=";
const asiv = "HIkJ6JB5zOhaYRTdfLt9+A==";
if (!value || value === '') return '';
try {
const key = Buffer.from(asevkry, 'base64');
const iv = Buffer.from(asiv, 'base64');
// Replace spaces with '+' as in the original C# code
value = value.replace(/ /g, '+');
const encryptedBuffer = Buffer.from(value, 'base64');
const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
let decrypted = decipher.update(encryptedBuffer);
decrypted = Buffer.concat([decrypted, decipher.final()]);
return decrypted.toString('utf8');
} catch (error) {
console.error('Decryption error:', error.message);
return '';
}
}