$adminPhoneParam]); jsonError('Access denied for this admin phone.', 403); } if (empty($text) || ($action !== 'encrypt' && $action !== 'decrypt')) { jsonError('Invalid input: need action=encrypt|decrypt and non-empty text.', 400); } // 4) تنفيذ التشفير / الفك (التوافق مع CBC الحالي) try { if ($action === 'encrypt') { $result = $encryptionHelper->encryptData($text); } else { // decrypt $result = $encryptionHelper->decryptData($text); } jsonSuccess([ 'action' => $action, 'result' => (string) $result, ]); } catch (Exception $e) { securityLog("Encryption tool failed", ['error' => $e->getMessage()]); jsonError('Operation failed.', 500); }