Sources:
As for God, his way is perfect: The Lord’s word is flawless; he shields all who take refuge in him. - 2 Samuel 22:31
Prayer Against Evil on Thoughts
Holy God, I surrender to You my heart and my mind for cleansing. I know You desire for us to love You wholeheartedly and willfully. Keep my mind from evil thoughts. Steer it away from the influences of wicked imaginations. Help me take every thought of mine captive to Your obedience, that I may experience joy in You. Put a hedge of protection around my mind. Help me will my thoughts to dwell on what is good, true, and positive. Amen.
Sources:
Original version of the prayer: https://connectusfund.org/25-powerful-prayers-for-protection-against-evil