The Greek phrase is most famously preserved in the Republic, book 1, 332δ. In the quote, Polemarchus summarizes his interpretation of Simonides's definition of justice:
ἡ οὖν δὴ τίσιν τί ἀποδιδοῦσα τέχνη δικαιοσύνη ἂν καλοῖτο;
εἰ μέν τι, ἔφη, δεῖ ἀκολουθεῖν, ὦ Σώκρατες, τοῖς ἔμπροσθεν εἰρημένοις, ἡ τοῖς φίλοις τε καὶ ἐχθροῖς ὠφελίας τε καὶ βλάβας ἀποδιδοῦσα.
τὸ τοὺς φίλους ἄρα εὖ ποιεῖν καὶ τοὺς ἐχθροὺς κακῶς δικαιοσύνην λέγει;
My literal translation:
Socates: [Given the above], the art that renders what thing to whom should be called justice?
Polemarchus: If we must keep with what has been said previously, Socrates, it is the art that renders help and harm to friends and foes [respectively].
Socrates: So [Simonides] says that justice is doing well to friends and ill to enemies?
Polemarchus: So it seems.
A very similar thought is expressed in Xenophon's Memorabilia 2.6.35:
...ἔγνωκας ἀνδρὸς ἀρετὴν εἶναι νικᾶν τοὺς μὲν φίλους εὖ ποιοῦντα, τοὺς δ᾽ ἐχθροὺς κακῶς....
A parallel Latin thought can be found in Plautus, Captivi, IV.1:
nam vél prodesse amico possum vel inimicum perdere,
ita híc me amoenitate amoena amoenus oneravit dies.
For now I can either benefit a friend or destroy an enemy,
for so has this wonderful day wonderfully heaped wonderful things on me.
Obviously, Plautus is not a philosophical authority, and this seems more like gloating than moralizing. I will update if I find more examples, but strangely enough it doesn't seem to have an explicit formulation in Latin literature.
Obviously, the primary source of this idea is from the Sermon on the Mount, where Jesus explicitly goes against this idea:
Ἠκούσατε ὅτι ἐρρέθη· Ἀγαπήσεις τὸν πλησίον σου καὶ μισήσεις τὸν ἐχθρόν σου. (Mt 5:43)
The Vulgate has:
audistis quia dictum est diliges proximum tuum et odio habebis inimicum tuum.
It's a subject of contention where this previous idea comes from. The Old Testament speaks of "loving one's neighbor" but not of "hating one's enemy." A few sources (such as this one) attribute it to Qumran Community Rule discovered with the Dead Sea Scrolls. What is clear, though, is that this was not an explicitly formulated rule bandied about by Romans.