Sahih Muslim Book 45, Hadith 115
Jabir reported Allah's Apostle (ﷺ) a hadith like it but with a slight variation of wording.
O Allah, I am a human being and for any person amongst Muslims upon whom I hurl malediction or invoke curse or give him whipping make it a source of purity and mercy.
Make it a source of reward, and in the hadith transmitted on the authority of Abu Huraira (the words are):" Make it a source of mercy."