
In the battle against disordered desires the baptized person is able, by the grace of God, to achieve purity of heart through the virtue and gift of chastity, through purity of intention, purity of vision (both exterior and interior), discipline of the imagination and of feelings and by prayer.
Further reading: CCC 2520
530. What are the other requirements for purity?
Purity requires modesty which, while protecting the intimate center of the person, expresses the sensitivity of chastity. It guides how one looks at others and behaves toward them in conformity with the dignity of persons and their communion. Purity frees one from widespread eroticism and avoids those things which foster morbid curiosity. Purity also requires a purification of the social climate by means of a constant struggle against moral permissiveness which is founded on an erroneous conception of human freedom.
Further reading: CCC 2521-2527, 2533