Anas (may Allah be pleased with him) reported that whenever the Prophet (ﷺ) went to relieve himself he would say, "Allāhumma innī aʿūdhu bika min al-khubthi wa'l-khabā'ith" — "O Allah, I seek refuge in You from male and female devils" (Sahih al-Bukhari 142). On leaving, ʿĀ'ishah reported that he would say "Ghufrānak" — "I seek Your forgiveness" (Sunan Abi Dawud 30, Jāmiʿ at-Tirmidhī 7 and Sunan Ibn Mājah 300, graded ṣaḥīḥ). The fuqahā' also recommend entering with the left foot and leaving with the right, by analogy with the general Sunnah of favouring the right for honourable things. The supplication of entry is said before going in; if one is already inside a modern bathroom, the scholars advise saying it before stepping in or in the heart, since audible dhikr is disliked in that place.
Q&A · Dua & Dhikr
What do I say when entering and leaving the bathroom?
Evidence — the daleel
On deen2u
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.