Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:66:3

And ˹remember˺ when the Prophet confided to one of his wives a statement; and when she informed ˹another˺ of it and Allah showed it to him, he made known part of it and ignored a part. And when he informed her about it, she said, "Who told you this?" He said, "I was informed by the Knowing, the Acquainted."  

And, mention, when the Prophet confided to one of his wives, namely, Hafsa, a certain matter, which was his prohibition of Māriya, telling her: ‘Do not reveal it!’; but when she divulged it, to ‘Ā’isha, reckoning there to be no blame in ˹doing˺ such a thing, and God apprised him, He informed him, of it, of what had been divulged, he announced part of it, to Hafsa, and passed over part, out of graciousness on his part. So when he told her about it, she said, ‘Who told you this?’ He said, ‘I was told by the Knower, the Aware’, namely, God.
القرآن:٦٦:٣

وَإِذْ أَسَرَّ النَّبِيُّ إِلَىٰ بَعْضِ أَزْوَاجِهِ حَدِيثًا فَلَمَّا نَبَّأَتْ بِهِ وَأَظْهَرَهُ اللَّهُ عَلَيْهِ عَرَّفَ بَعْضَهُ وَأَعْرَضَ عَنْ بَعْضٍ ۖ فَلَمَّا نَبَّأَهَا بِهِ قَالَتْ مَنْ أَنْبَأَكَ هَٰذَا ۖ قَالَ نَبَّأَنِيَ الْعَلِيمُ الْخَبِيرُ  

{و} اذكر {إذ أسرَّ النبي إلى بعض أزواجه} هي حفصة {حديثا} هو تحريم مارية وقال لها لا تفشيه {فلما نبأت به} عائشة ظنا منها أن لا حرج في ذلك {وأظهره الله} أطلعه {عليه} على المنبأ به {عرَّف بعضه} لحفصة {وأعرض عن بعض} تكرما منه {فلما نبأها به قالت من أنبأك هذا قال نبأني العليم الخبير} أي الله.