Update: 2026-06-16 01:17:28
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
<?php
|
||||
//encrypt_decrypt.php
|
||||
// ⚠️ هذا الملف للتوافقية فقط. استخدم core/Security/EncryptionHelper.php للتشفير الجديد
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
require_once 'load_env.php';
|
||||
$env_file = '/home/siro-api/env/.env';
|
||||
loadEnvironment($env_file);
|
||||
|
||||
|
||||
$key = trim(file_get_contents('/home/siro-api/.enckey'));
|
||||
// ✅ FIX C-02: استخدام getenv بدلاً من file_get_contents الثابت
|
||||
$keyPath = getenv('ENCRYPTION_KEY_PATH');
|
||||
$key = '';
|
||||
if ($keyPath && file_exists($keyPath)) {
|
||||
$key = trim(file_get_contents($keyPath));
|
||||
}
|
||||
if (!$key) {
|
||||
$key = getenv('ENC_KEY') ?: '';
|
||||
}
|
||||
$iv = getenv('initializationVector'); // 16 bytes
|
||||
|
||||
|
||||
@@ -77,6 +85,11 @@ class EncryptionHelper {
|
||||
|
||||
$encryptedData = file_get_contents($encryptedFilePath);
|
||||
$decryptedData = openssl_decrypt($encryptedData, 'AES-256-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv);
|
||||
|
||||
if ($decryptedData === false) {
|
||||
error_log("[ERROR] openssl_decrypt failed for file: $encryptedFilePath");
|
||||
throw new Exception("❌ فشل فك تشفير الملف: $encryptedFilePath");
|
||||
}
|
||||
|
||||
file_put_contents($destinationPath, $decryptedData);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user