From b9efba37872d2d81974eac25773a547078f7ba46 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Wed, 22 Jul 2026 18:32:11 +0300 Subject: [PATCH] Update: 2026-07-22 18:32:11 --- backend/core/Security/EncryptionHelper.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/backend/core/Security/EncryptionHelper.php b/backend/core/Security/EncryptionHelper.php index dd2ac923..d410f8f1 100644 --- a/backend/core/Security/EncryptionHelper.php +++ b/backend/core/Security/EncryptionHelper.php @@ -59,26 +59,12 @@ class EncryptionHelper return $plain !== false ? $plain : false; } - // وإلا استخدم CBC القديم (دعم IV العشوائي المسبوق و IV الثابت) + // وإلا استخدم CBC القديم $decoded = base64_decode($cipherText, true); if ($decoded === false) return false; - // محاولة أولى: IV عشوائي مسبوق (أول 16 بايت) - if (strlen($decoded) >= 32) { - $iv = substr($decoded, 0, 16); - $payload = substr($decoded, 16); - $decrypted = openssl_decrypt($payload, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $iv); - if ($decrypted !== false && strlen($decrypted) > 0) { - $pad = ord($decrypted[strlen($decrypted) - 1]); - if ($pad >= 1 && $pad <= 16) { - return substr($decrypted, 0, -$pad); - } - } - } - - // محاولة ثانية: IV ثابت $decrypted = openssl_decrypt($decoded, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $this->cbcIv); - if ($decrypted === false || strlen($decrypted) === 0) return false; + if ($decrypted === false) return false; $pad = ord($decrypted[strlen($decrypted) - 1]); if ($pad < 1 || $pad > 16) return false;