Niccolò Machiavelli said this quote

Thus it is well to seem merciful, faithful, humane, sincere, religious, and also to be so; but you must have the mind so disposed that when it is needful to be otherwise you may be able to change to the opposite qualities. And it must be understood that a prince, and especially a new prince, cannot observe all those things which are considered good in men, being often obliged, in order to maintain the state, to act against faith, against charity, against humanity, and against religion. And, therefore, he must have a mind disposed to adapt itself according to the wind, and as the variations of fortune dictate, and, as I said before, not deviate from what is good, if possible, but be able to do evil if constrained.