Few workers know this, and even some companies don't know this. Companies are legally not allowed to put a rule disallowing the sharing of salary information in employee handbooks or contracts. Managers and HR are are not allowed to tell workers that sharing salary information is prohibited, because it is a right protected by law.
The right for workers to share salary information was granted by the National Labor Relations Act (NLRA) of 1935. Courts have upheld this right over the years, including recently.
You can read this yourself on the Department of Labor's web site