The Prophet ﷺ said, "Whoever fasts Ramadan out of faith and seeking reward, his previous sins will be forgiven, and whoever stands in prayer during Laylat al-Qadr out of faith and seeking reward, his previous sins will be forgiven."
عن النبي ﷺ قال: من صام رمضان إيمانا واحتسابا، غفر له ما تقدم من ذنبه، ومن قام ليلة القدر إيمانا واحتسابا غفر له ما تقدم من ذنبه.
Bukhari narrated it in the Book of Fasting (1901), and Muslim in the Book of the Prayer of Travelers (760), both through Hisham Dastawai, who said, Yahya bin Abu Kathir told us, Abu Salama bin Abdul-Rahman told us, that Abu Hurairah told them the hadith, and he related it.