Update: 2026-07-22 18:32:11

This commit is contained in:
Hamza-Ayed
2026-07-22 18:32:11 +03:00
parent e798f84c03
commit b9efba3787
+2 -16
View File
@@ -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;