Sahih Muslim Book 17, Hadith Number 4237.

Chapter : Imposition of Hadd obliterates sins.

‘Ubida b. as-Samit reported: Allah’s Messenger (may peace be upon him) took (a pledge) from us as he took from the women that we will not associate anything with Allah and we will not steal, and we will not commit adultery, and we will not kill our children, and we will not bring calumny upon one another. And he who amongst you fulfils (this pledge), his reward rests with Allah, and he upon whom amongst you is imposed the prescribed punishment and that is carried out, that is his expiation (for that sin), and he whose (sins) were covered by Allah, his matter rests with Allah. He may punish him if He likes or may forgive him if He so likes.