<?php

// Secret key same use करना जो encrypt code में इस्तेमाल किया है
$secret_key = "MySecretKey123";

// decrypt function
function decryptData($enc, $key) {
    return openssl_decrypt(base64_decode($enc), "AES-128-ECB", $key);
}

// Read log file
$logFile = "lead_full_log.txt";  // <-- encrypted log file ka naam

if (!file_exists($logFile)) {
    die("❌ Log file not found!");
}

$lines = file($logFile);

echo "<pre>";

foreach ($lines as $line) {

    // extract encrypted text from log line
    if (preg_match('/ENCRYPTED:\s*(.*?)\s*$/', $line, $match)) {

        $encryptedText = trim($match[1]);
        $decrypted = decryptData($encryptedText, $secret_key);

        echo "🔓 Decrypted: $decrypted \n\n";

    } else {
        echo "⚠ SKIPPED (Not Encrypted): $line\n";
    }
}

echo "</pre>";
?>
