Whenever the Prophet ﷺ entered the toilet, he would say, "Allah, I seek refuge in You."Shuba said, "On another occasion he said, 'I seek refuge in You from male and female evil,' or, 'from evil and evil ones.'"
حدثنا قتيبة وهناد قالا حدثنا وكيع عن شعبة عن عبد العزيز بن صهيب
كان النبي ﷺ إذا دخل الخلاء قال اللهم إني أعوذ بك قال شعبة وقد قال مرة أخرى أعوذ بك من الخبث والخبيث أو الخبث والخبائث
Its isnad is sahih. It was also narrated by Abu Dawud in the Book of Purification, in the chapter on what a man says when entering the toilet, hadith, from the narration of Waki with the same wording, and it is agreed upon [Bukhari, hadith 142, from the narration of Shubah, and Muslim, hadith 375, from the narration of Abdul-Aziz with the same wording]. See the following hadith.On this subject there are also narrations from Ali [to come, 606], Zayd bin Arqam [Abu Dawud, hadith 6, and Ibn Majah, hadith 296], Jabir [we did not find it], and Ibn Masud [Khatib in Tarikh Baghdad, 4/262].