'error', 'message' => 'Access denied for this admin phone.', ]); exit; } // 3) التحقق من بقية المدخلات (action + text) $action = $data['action'] ?? ''; $text = trim($data['text'] ?? ''); if ($text === '' || ($action !== 'encrypt' && $action !== 'decrypt')) { http_response_code(400); echo json_encode([ 'status' => 'error', 'message' => 'Invalid input: need action=encrypt|decrypt and non-empty text.', ]); exit; } // 4) تنفيذ التشفير / الفك try { // require_once __DIR__ . '/encrypt_decrypt.php'; if ($action === 'encrypt') { $result = $encryptionHelper->encryptData($text); } else { // decrypt $result = $encryptionHelper->decryptData($text); } echo json_encode([ 'status' => 'success', 'action' => $action, 'result' => (string) $result, ]); } catch (Exception $e) { http_response_code(500); echo json_encode([ 'status' => 'error', 'message' => 'Operation failed.', ]); }