That's certainly true, and for most of us in the US, it's also true that as an at-will employee at a company, you're only protected by what the law
covers. The list of things it doesn't cover is long enough that it's not terribly difficult to find a reason that
is legal to cover-up the real reason.
There's the bigger problem with sharing your salary openly: raises.
My dad told me when I started working "Don't talk about your salary unless you don't want to see a raise again." It's not that absolute in practice. For many, raises are doled out yearly and are an average percentage with discretion to give some more and some less than the target. Even when well deserved, it's not easy to squeeze into the higher percentage but one way to make it a whole lot more difficult is to be revealed as someone who'll tell all the coworkers what they received. That'll almost certainly be on your bosses mind when it comes time for that decision and you might find yourself fighting to get an average raise since giving you the lower raise has the added benefit of making everyone else think they did better.
Share it on the Internet, openly, and now everyone in the company can know what you make. If you're paid over-average, your boss might even get a phone call asking "why?". That's just not a good place to be.