Fix OTP verification success response payload and restore deterministic encryptData

This commit is contained in:
Hamza-Ayed
2026-06-24 23:11:20 +03:00
parent 7b0283473e
commit 2ee3a14c6d
2 changed files with 48 additions and 7 deletions

View File

@@ -24,14 +24,13 @@ class EncryptionHelper
$this->cbcIv = $cbcIv ?: getenv('initializationVector') ?: str_repeat('0', 16);
}
// ─── تشفير نص باستخدام AES-256-GCM ──
// ─── تشفير نص باستخدام AES-256-CBC الحتمي ──
public function encryptData(string $plainText): string
{
$plainText = mb_convert_encoding($plainText, 'UTF-8');
$iv = random_bytes(self::IV_LEN_GCM);
$tag = '';
$encrypted = openssl_encrypt($plainText, self::ALGO_GCM, $this->key, OPENSSL_RAW_DATA, $iv, $tag, "", self::TAG_LEN);
return self::PREFIX_GCM . base64_encode($iv . $tag . $encrypted);
$padded = $this->addPadding($plainText);
$encrypted = openssl_encrypt($padded, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $this->cbcIv);
return base64_encode($encrypted);
}
// ─── فك تشفير نص (يدعم CBC والـ GCM المستقبلي) ───────────