Investors have radically different outlooks for Palo Alto Networks (PANW 0.30%) and Okta (OKTA 1.12%). Even though both companies are in the cybersecurity industry, which has a bright long-term outlook, their stocks have been on divergent paths through most of 2022. Okta shares are down over 70% through mid-December while Palo Alto Networks is down 13%.

Those declines could set the stage for excellent returns for investors willing to hold either of these stocks for the long term. But which one would make the better buy today? Let's take a closer look.

Recent trends

Palo Alto Networks easily wins in the growth matchup, although both companies are expanding today. Okta's most recent report showed a 37% sales increase while Palo Alto grew at a 25% pace.

Keep in mind, though, that Palo Alto Networks is growing from a much larger sales base. Management has raised its revenue forecast in recent quarters, too, thanks to continued strong demand for its wide platform of cybersecurity services.

Okta, on the other hand, has lost a step since its acquisition of the Auth0 business. Management warned in a recent conference call with investors that "it will take several quarters to regain top-line momentum in the business." That's why, if you're looking for the company with a clearer growth path, then Palo Alto Networks is your stock.

Profit margins

Strong growth makes it easier to generate profits, and that's exactly what investors are seeing with Palo Alto Networks right now. The company has recently broken into net profitability for the first time in several years, and management intends to protect that young streak. Palo Alto Networks is generating plenty of cash and has a good shot at increasing profit margin even through a weaker selling environment.

OKTA Operating Margin (TTM) Chart

OKTA Operating Margin (TTM) data by YCharts

Okta recently raised its profit outlook, which was great news for the stock. However, the company is still projecting losses this fiscal year. Non-GAAP (adjusted) losses will land at roughly $40 million, executives said in late November, compared to their prior forecast of over $100 million of red ink. The financial edge goes to Palo Alto Networks.

The better deal

As you might expect, Okta shares look much cheaper than Palo Alto Networks' shares today. You can buy the stock at less than 6 times sales right now, roughly the lowest valuation to date for the business. Palo Alto Networks is valued at nearly 9 times annual sales, in contrast, or roughly what you'd pay to own Microsoft today.

Of course, Palo Alto Networks has nothing approaching the scale, profitability, or predictability that Microsoft enjoys. It doesn't pay a dividend, either. But the stock still looks attractive compared to Okta and other peers in the software-as-a-service industry.

The next few quarters might bring volatility, especially if enterprises pull back on their IT spending. But the cybersecurity niche will likely be central to tech budgets for many years to come. Investing in a leader like Palo Alto Networks should pay off for patient investors.