"Whenever the Messenger of Allah entered the mosque he would say: 'Bismillah, was-salamu 'ala Rasulillah, Allahummagh-firli dhunubi waftah li abwaba rahmatika. (In the Name of Allah, and peace be upon the Messenger of Allah. O Allah, forgive me my sins and open to me the gates of Your mercy).' When he left he would say: 'Bismillah, was-salamu 'ala Rasulillah, Allahummagh-firli dhunubi waftah li abwaba fadlika. (In the Name of Allah, and peace be upon the Messenger of Allah. O Allah, forgive me my sins and open to me the gates of Your bounty).'" (Using translation from Ibn Mājah 771)
عَنْ جَدَّتِهَا فَاطِمَةَ بِنْتِ رَسُولِ اللهِ ﷺ قَالَتْ كَانَ رَسُولُ اللهِ ﷺ إِذَا دَخَلَ الْمَسْجِدَ قَالَ بِسْمِ اللهِ وَالسَّلَامُ عَلَى رَسُولِ اللهِاللهُمَّ اغْفِرْ لِي ذُنُوبِي وَافْتَحْ لِي أَبْوَابَ رَحْمَتِكَ وَإِذَا خَرَجَ قَالَ بِسْمِ اللهِ وَالسَّلَامُ عَلَى رَسُولِ اللهِ اللهُمَّ اغْفِرْ لِي ذُنُوبِي وَافْتَحْ لِي أَبْوَابَ فَضْلِكَ