No, it is not illegal. It is highly unusual or improper (at least, if your friend didn't work in human resoiurces or payroll or some other capacity in which case they would normally have access to payroll information). It may also be against company policy, and if you feel strongly enough about it, you could talk to your boss's boss. But it is not in fact illegal.