Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
abudawud:4Musaddad b. Musarhad > Ḥammād b. Zayd And ʿAbd al-Wārith > ʿAbd al-ʿAzīz b. Ṣuhayb > Anas b. Mālik

When the Apostle of Allaah (sal Allahu alayhi wa sallam) entered the toilet, he used to say (before entering): "O Allaah, I seek refuge in Thee." This is according to the version of Hammad. 'Abd al-Warith has another version :"I seek refuge in Allaah from male and female devils."  

أبو داود:٤حَدَّثَنَا مُسَدَّدُ بْنُ مُسَرْهَدٍ حَدَّثَنَا حَمَّادُ بْنُ زَيْدٍ وَعَبْدُ الْوَارِثِ عَنْ عَبْدِ الْعَزِيزِ بْنِ صُهَيْبٍ عَنْ أَنَسِ بْنِ مَالِكٍ قَالَ

كَانَ رَسُولُ اللَّهِ ﷺ إِذَا دَخَلَ الْخَلاَءَ قَالَ عَنْ حَمَّادٍ قَالَ اللَّهُمَّ إِنِّي أَعُوذُ بِكَ وَقَالَ عَنْ عَبْدِ الْوَارِثِ قَالَ أَعُوذُ بِاللَّهِ مِنَ الْخُبُثِ وَالْخَبَائِثِ قَالَ أَبُو دَاوُد رَوَاهُ شُعْبَةُ عَنْ عَبْدِ الْعَزِيزِ اللَّهُمَّ إِنِّي أَعُوذُ بِكَ وَقَالَ مَرَّةً أَعُوذُ بِاللَّهِ و قَالَ وُهَيْبٌ فَلْيَتَعَوَّذْ بِاللَّهِ