Profanity is now encountered at every step. Sometimes you can hear obscenities in your address. Answering the swearing man or keeping silent is a real dilemma. In any case, do not be like your abuser, be higher.
For a start, just try not to run into such people, do not ask for trouble or do not fall under the hot hand. If the person is on edge, don't ask stupid questions or try to make an inappropriate joke. This can cause a storm of rage, and then the flow of hard-hitting words in your direction cannot be avoided.
In case this did happen, do not throw insults at him. This will only make matters worse, not help you maintain your dignity in the fight. Timely humor is the best way out of this situation. Try to make the aggressor laugh. Laughter neutralizes rudeness. Behave yourself, do not explode with emotions like an atomic bomb.
If on the Internet you run into an inadequate user or troll, ignore him. He is a stranger to you, which means that you should not worry about ruined good relations. There was a man - and there is no man. Your mental health is more valuable.