‘Ali reported God’s messenger as saying, "The covering between the eyes of the jinn and the private parts of the children of Adam when one of them enters the privy is provided by his saying, ‘In the name of God.’”
Tirmidhi transmitted it, saying that this is a gharib tradition and that its isnad is not strong.
Zaid b. Arqam reported God's messenger as saying, "These privies are peopled by jinn and devils, so when one of you goes there he should say, ‘I seek refuge in God from male and female devils.”
Abu Sa'id reported God’s messenger as saying, "Two people should not go together to relieve themselves and uncover their private parts and talk, for God is angry with that.”