Secret Service Agent Matt O'Neill did just that during a three-year undercover investigation that began in 2008 into the point-of-sale hacking at Subway sandwich franchises and other retailers.

Being a Secret Service agent requires extraordinary bravery. But sometimes, it also requires flirting with a Romanian hacker.

An undercover secret service agent posing with a sign designed to lure a Romanian hacker to come to the United States.

He told the story in Washington on Monday during a joint Secret Service and FBI session with the Financial Services Roundtable on cybersecurity.

O'Neill said he contacted the suspected hacker by posing as a female casino employee in an effort to entice him to come to the United States for what he thought would be a gambling outing. That way, the Secret Service could arrest him on U.S. soil, rather than go to the trouble of extraditing him from Romania.

The Secret Service worked with an American hotel and casino to create a fictitious employee, "Sarah," who had an email address and direct phone line at the hotel and her name on the hotel's online directory. The fake employee would appear real if the suspected hacker tried to check out her story. Agents even photographed a young undercover female agent with a sign saying "hi!" inside the hotel's lobby, and sent the image to the Romanian.

Read MoreWhy the Secret Service story could actually matter in the midterms



O'Neill said over the next several months he developed a "quasi-romantic" relationship with the suspect, at times chatting online with him at 3 a.m. while he fed his newborn baby as his wife slept in another room at home.

"People say everyone has a gift," O'Neill joked. "And mine happens to be chatting with men."

The suspect, Iulian Dolan, flew to Boston to meet the supposed casino employee. When he arrived, investigators said, he was carrying a gold necklace for her as a gift, along with three boxes of grape-flavored condoms.

He was arrested and is now serving a seven-year sentence in federal prison in Mississippi.