How to Wipe Out Sins, Public or Private
Imām Ibn Taimiyyah, may Allāh have mercy on him, said:
[I]f [someone] sins in private, between himself and Allāh, he acknowledges his sin before his Lord, subjects himself humbly to Him with his heart, asks forgiveness of Him, and repents to Him, for indeed, He is ever-forgiving, ever-caring and merciful, ever-guiding to and accepting of repentance.
And if the sin were public, he repents publicly. And if what he had shown in public looked good while what he had concealed inside was repulsive, he repents from that which had been concealed of repulsiveness.
So whoever does evil in private, should [then] do good in private, and whoever does evil in public, should [then] do good publicly.
إِنَّ الْحَسَنَاتِ يُذْهِبْنَ السَّيِّئَاتِ ۚ ذَٰلِكَ ذِكْرَىٰ لِلذَّاكِرِينَ
Indeed, good deeds wipe out [prior] evil deeds; that is a [lesson and] reminder to be taken to heart by those who [will] keep [it] in mind. (Hūd, 114)
Majmūʿ Al-Fatāwá, vol. 14, pp. 447.