Mohamed Salah scored a first-half penalty as 10-man Egypt defeated South Africa to become the first team into the Africa Cup of Nations round of 16.