Allah (swt) has not given the permission to do friendship with non-mehrams but nowadays people make friends at the drop of a hat. This is a satanic thing. Satan wants the people to disobey Allah (swt) because he is their enemy but people do not understand this. Allah (SWT) says in the holy Quran:
If any of you have not the means wherewith to wed free believing women, they may wed believing girls from among those whom your right hands possess: And Allah hath full knowledge about your faith. Ye are one from another: Wed them with the leave of their owners, and give them their dowers, according to what is reasonable: They should be chaste, not lustful, nor taking paramours: when they are taken in wedlock, if they fall into shame, their punishment is half that for free women. This (permission) is for those among you who fear sin; but it is better for you that ye practise self-restraint. And Allah is Oft-forgiving, Most Merciful.
surah nisa verse no 25
30Say to the believing men that they should lower their gaze and guard their modesty: that will make for greater purity for them: And Allah is well acquainted with all that they do.
31And say to the believing women that they should lower their gaze and guard their modesty; that they should not display their beauty and ornaments except what (must ordinarily) appear thereof; that they should draw their veils over their bosoms and not display their beauty except to their husbands, their fathers, their husband's fathers, their sons, their husbands' sons, their brothers or their brothers' sons, or their sisters' sons, or their women, or the slaves whom their right hands possess, or male servants free of physical needs, or small children who have no sense of the shame of sex; and that they should not strike their feet in order to draw attention to their hidden ornaments. And O ye Believers! turn ye all together towards Allah, that ye may attain Bliss.
surah noor verse no 30,31
59O Prophet! Tell thy wives and daughters, and the believing women, that they should cast their outer garments over their persons (when abroad): that is most convenient, that they should be known (as such) and not molested. And Allah is Oft- Forgiving, Most Merciful.
surah ahzab verse no 59
53 O ye who believe! Enter not the Prophet's houses,- until leave is given you,- for a meal, (and then) not (so early as) to wait for its preparation: but when ye are invited, enter; and when ye have taken your meal, disperse, without seeking familiar talk. Such (behaviour) annoys the Prophet: he is ashamed to dismiss you, but Allah is not ashamed (to tell you) the truth. And when ye ask (his ladies) for anything ye want, ask them from before a screen: that makes for greater purity for your hearts and for theirs. Nor is it right for you that ye should annoy Allah.s Messenger, or that ye should marry his widows after him at any time. Truly such a thing is in Allah.s sight an enormity.
surah ahzab verse no 53
Nor come nigh to adultery: for it is a shameful (deed) and an evil, opening the road (to other evils).
surah al isra verse no 32
Narrated Hazrat Jabir (R.A) that one day I asked Huzur (saws) that what I should do if my eyes happen to fall upon a non-mehram woman, all of a sudden? Huzur (saws) replied, “Look in some other direction”.