مِشْكَاةُ الْمَصَابِيحِ
Mishkat al-Masabih 337
Purification
How to act when relieving oneself - Section 1
وَعَنْ أَنَسٍ قَالَ: كَانَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذَا دَخَلَ الْخَلَاءَ يَقُولُ: «اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنَ الْخبث والخبائث»
Anas reported that when God’s messenger entered the privy he used to say, "O God, I seek refuge in You from male and female devils.”* *One might be inclined to translate this phrase as "from infidelity and act of disobedience,” but the tradition from Zaid b. Arqam (p. 76) is very explicit, and so the translation above is probably the correct one. PT-2 (12-71.) (Bukhari and Muslim).
Mishkat al-Masabih, 337مُتَّفَقٌ عَلَيْهِ (الألباني)