Abu Hurairah reported,

The Messenger of Allah ﷺ said, "A man said, 'I will certainly give a charity tonight.' So he went out with his charity and placed it in the hand of a thief. The next morning people were talking, saying, 'Charity was given to a thief last night!'He said, 'O Allah, to You belongs all praise. I will certainly give another charity.' So he went out with his charity and placed it in the hand of an adulteress. The next morning people were talking, saying, 'Charity was given to an adulteress last night!'He said, 'O Allah, to You belongs all praise for the adulteress. I will certainly give another charity.' So he went out with his charity and placed it in the hand of a wealthy man. The next morning people were talking, saying, 'Charity was given to a wealthy man!'He said, 'O Allah, to You belongs all praise for the thief, the adulteress, and the wealthy man.'Then he was approached and told, 'As for your charity to the thief, perhaps it will keep him from his theft. As for the adulteress, perhaps it will keep her from her adultery. And as for the wealthy man, perhaps he will take heed and spend from what Allah has given him.'"

Bukhari 1421

Sahih

حدثنا أبو اليمان أخبرنا شعيب حدثنا أبو الزناد عن الأعرج

عن أبي هريرة رضي الله عنه

أن رسول الله ﷺ قال قال رجل لأتصدقن بصدقة فخرج بصدقته فوضعها في يد سارق فأصبحوا يتحدثون تصدق على سارق فقال اللهم لك الحمد لأتصدقن بصدقة فخرج بصدقته فوضعها في يدي زانية فأصبحوا يتحدثون تصدق الليلة على زانية فقال اللهم لك الحمد على زانية لأتصدقن بصدقة فخرج بصدقته فوضعها في يدي غني فأصبحوا يتحدثون تصدق على غني فقال اللهم لك الحمد على سارق وعلى زانية وعلى غني فأتي فقيل له أما صدقتك على سارق فلعله أن يستعف عن سرقته وأما الزانية فلعلها أن تستعف عن زناها وأما الغني فلعله يعتبر فينفق مما أعطاه الله

البخاري 1421صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Zakat
Chapter
If one gives charity to a wealthy person without knowing
Numbering
Darussalam 1421
Bukhari 1421