You’re absolutely right.
The Barbary pirates were Islamic and preyed upon shipping. After the Revolution the American shipping no longer had the protection of the British Navy or the funding to pay ransom to free American shipping or sailors.
Many of the contemporaries wrote about this in their letter to each other.