بسم الله الرحمن الرحيم
Ibn ‘Umar narrated that he heard the Messenger of Allah ﷺ say:
يدنو المؤمن من ربه حتى يضع عليه كنَفَه فيقرره بذنوبه: تعرف ذنب كذا يقول أعرف يقول رب أعرف مرتين فيقول سترتها في الدنيا وأغفرها لك اليوم ثم تطوى صحيفة حسناته
❝The believer will be brought close to his Rabb until He covers him and makes him confess his sin. Allah will Say, ‘Do you remember such and such a sin?’ The man will say, ‘Yes, I admit it.’ Al-Rabb will Say, ‘I concealed it for you in the world and I forgive you for it today.’ He will then close his record of good deeds.❞ 
There is a growing tendency among people, and especially the youth to speak about their past objectionable deeds, whether prior to finding guidance and commencing to practice the Deen, or what they indulge in presently. They bring to attention their wrongdoings and sometimes do it in a proud boastful manner.
One’s past experiences can have a valid purpose in encouraging others to stay away from sinful habits, but usually it also reflects negatively on the person and judgements that are assumed. It also risks enticing others to seek committing those very misdeeds!
Imam Ibn Rajab al-Hanbali said:
وجمهور العلماء على أن من تاب من ذنب, فالأصل أن يستر على نفسه, ولا يقر به عند أحد, بل يتوب منه فيما بينه وبين الله عز وجل
“Majority of scholars are of the position that anyone who repents from sin, the original stance is to cover up (the wrongdoing) and not to admit (or confess) to anyone. But repent from it and leave it (known) between himself and Allah ﷻ.” 
Therefore just as tawbah is between us and Allah ﷻ, so too are our wrongdoings. It is from His Mercy that our failures and shortcomings are veiled from people so that we may lead normal and dignified lives in society without the burden of facing shame. So what of those who publicise what had been kept concealed? Abu Hurayrah narrated that he heard the Messenger of Allah ﷺ say:
كل أمتي معافى إلا المجاهرين، وإن من المجاهرة أن يعمل الرجل بالليل عملاً ثم يصبح وقد ستره الله عليه فيقول يا فلان عملت البارحة كذا وكذا وقد بات يستره ربه ويصبح يكشف ستر الله عنه
❝All of my ummah will be forgiven except those who sin openly. It is a part of sinning openly when a man does something at night, then the following morning, when Allah has concealed his sin, he says, ‘O so and so, I did such and such last night,’ when all night his Rabb has concealed him and the next morning he uncovers what Allah had concealed.❞ 
‘Umar ibn ‘Abd Al-Azeez said:
إن الله تبارك وتعالى لا يعذب العامة بذنب الخاصة، ولكن إذا عُمل المنكر جهارا، استحقوا العقوبة كلهم
“Allah تبارك وتعالى will not punish the general masses for their particular sins, but if their evil deeds are done publicly, they will all deserve punishment.” 
Al-Rabi’ bin Khaytham asked about the height of disease and what it was:
أتدرون ما الداء وما الدواء والشفاء قالو لا قال: الداء الذنوب والدواء الاستغفار والشفاء أن تتوب ثم لا تعود
“Do you know what is the disease and what is the cure and the healing? They said, ‘No’. He replied, ‘Disease is the sins, and the cure is repentance, and the healing is to repent and then not return (to the sin).” 
It is therefore from prudence to keep one’s deeds – good as well as the bad – to oneself and never divulge them. We hope that Allah ﷻ will multiply and reward our secret and sincere good deeds, while conceal and diminish our sins, for verily He alone is the one who accepts repentance and loves doing so.
 Agreed upon
 Fath al-Bari, 1/76
 Agreed upon
 Ibn Abi Dunya, ‘Al ‘amr bil ma’roof wan-nahiy-anil munkar’, 67
 Hilyat al-Awliya’, 1722