Fix OTP verification success response payload and restore deterministic encryptData
This commit is contained in:
@@ -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 المستقبلي) ───────────
|
||||
|
||||
Reference in New Issue
Block a user