Yahya said: I heard them saying that it is recommended that Zakat (obligatory charity) be given openly, while voluntary charity should be given privately.
Yahya narrated, from Malik ibn Sulayman, from al-Hasan, from Ka'b ibn 'Ujrah, who said: The Messenger of Allah (peace be upon him) said to me: "O Ka'b ibn 'Ujrah, prayer is a proof, fasting is a shield, and charity extinguishes sin just as water extinguishes fire. O Ka'b ibn 'Ujrah, people set out in the morning in two states: one sets out in the morning to buy his own soul and set it free, while another sets out in the morning to sell his soul and bring about its ruin."
قَالَ يَحْيَى: وسمعتهم يَقُولُونَ: يسْتَحبّ أَن تكون الزَّكَاة عَلَانيَة، وَصدقَة التَّطَوُّع سرا.
يَحْيَى: عَنْ مَالِكِ بْنِ سُلَيْمَانَ، عَنِ الْحَسَنِ، عَنْ كَعْبِ بْنِ عُجْرَةَ قَالَ: قَالَ لِي رَسُولُ اللَّهِ ﷺ: ((يَا كَعْبُ بْنَ عُجْرَةَ؛ الصَّلاةُ بُرْهَانٌ، وَالصَّوْمُ جُنَّةٌ، وَالصَّدَقَةُ تُطْفِئُ الْخَطِيئَةَ كَمَا يُطْفِئُ الْمَاءُ النَّارَ. يَا كَعْبُ بْنَ عُجْرَةَ؛ النَّاسُ غَادِيَانِ: فَغَادٍ فَمُشْتَرٍ رَقَبَتَهُ فَمُعْتِقُهَا، وَغَادٍ فَبَائِعٌ رَقَبَتَهُ فموبقها)).