Sahih al-Bukhari 2538
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
أَسْلَمْتَ عَلَى مَا سَلَفَ لَكَ مِنْ خَيْرٍ "
Narrated Hisham:
My father told me that Hakim bin Hizam manumitted one-hundred slaves in the Pre-Islamic period of ignorance and slaughtered one-hundred camels (and distributed them in charity). When he embraced Islam he again slaughtered one-hundred camels and manumitted one-hundred slaves. Hakim said, "I asked Allah's Messenger (ﷺ), 'O Allah's Messenger (ﷺ)! What do you think about some good deeds I used to practice in the Pre-Islamic period of ignorance regarding them as deeds of righteousness?' Allah's Apostle said, "You have embraced Islam along with all those good deeds you did."
Full reference and source
Sahih al-Bukhari 2538 In-book : Book 49, Hadith 23 USC-MSA web (English) : Vol. 3, Book 46, Hadith 715 (deprecated)
View source on Sunnah.com (opens in a new tab)