Sahih Muslim Book 17, Hadith Number 4235.

Chapter : Imposition of Hadd obliterates sins.

Ubida b. as-Samit reported: While we were in the company of Allah’s Messenger (may peace be upon him) he said: Swear allegiance to me that you will not associate anything with Allah, that you will not commit adultery, that you will not steal, that you will not take any life which it is forbidden by Allah to take but with (legal) justification; and whoever among you fulfils it, his reward is with Allah and he who commits any such thing and is punished for it, that will be all atonement for it And if anyone commits anything and Allah conceals (his favours), his matter rests with Allah. He may forgive if He likes, and He may punish him if He likes.