In Egypt, homosexuality is highly stigmatized, and there have long been allegations that police are hunting LGBT people online.
Now BBC News has seen evidence of how the authorities are using dating and social apps to do this.
All victims' names have been changed
Having grown up in Egypt, I am aware of the pervasive homophobia that permeates every part of its society.
But friends there tell me that the atmosphere has recently become far more brutal, and the tactics for tracking down LGBT people more sophisticated.
There is no explicit law against homosexuality in Egypt, but our investigation has found that the crime of "debauchery" - a sex work law - is being used to criminalise the LGBT community.
Transcripts submitted in police arrest reports show how officers are posing online to seek out - and in some cases allegedly fabricate evidence against - LGBT people looking for dates online.
They reveal how the police initiate text conversations with their targets.
Egypt is one of the most strategically important Western allies in the Middle East and receives billions of dollars in US and EU support every year. Around half a million British tourists visit the country annually and the UK trains Egyptian police forces, via the UN.
In one text conversation between an undercover police officer and someone using the social networking and dating app WhosHere, the officer appears to be pressuring the app user to meet up in person - that person was later arrested.
Police: Have you slept with men before?
App user: Yes
Police: How about we meet?
App user: But I live with mom and dad
Police: Come on dear, don't be shy, we can meet in public and then go to my flat.
There are more examples which are too explicit to publish.
It is extremely difficult for LGBT people to openly meet potential dates in public in Egypt, so dating apps are a popular way to do that. But just using the apps - regardless of your sexuality - can be grounds for arrest based on the incitement of debauchery or public morality laws in Egypt.
It is not just Egyptians who are being targeted. In one transcript, police describe identifying a foreigner, who we are calling Matt, on the popular gay dating app Grindr. A police informant then engaged Matt in conversation, and - the transcript says - Matt "admitted his perversion, his willingness to engage in debauchery for free, and sent pictures of himself and his body".
Matt told the BBC that he was subsequently arrested, charged with "debauchery", and eventually deported.
In some of the transcripts, the police appear to be trying to pressure people who seem to be simply seeking dates or new friendships into agreeing to sex for money. Legal experts in Egypt tell us that proving there has been an exchange of money, or an offer of one, can give the authorities the ammunition they need to take a case to court.
One such victim, whom we found through the transcripts, was a gay man we are calling Laith. In April 2018, the contemporary dancer was contacted from a friend's phone number.
"Hello, how are you?" the message said. The "friend" asked to meet for a drink.
But when Laith arrived to meet him, his friend was nowhere in sight. He was met instead by police who arrested him and threw him into a cell belonging to the vice squad.
One policeman stubbed a cigarette out on his arm, he told me, showing me the scar.
"It was the only time in my life that I tried to kill myself," Laith says.
He claims police then made a fake profile for him on the WhosHere app, and digitally altered his photos to make them look explicit. He says they then mocked up a conversation on the app which appeared to show him offering sex work.
He says the pictures are proof that he was framed, because the legs in the picture do not resemble his own - one of his legs is bigger than the other. The BBC has only had access to grainy photocopied police case files, so it cannot independently verify this detail.
Three other people told us the police forced or falsified confessions related to their cases, too.
Laith was jailed for three months for "habitual debauchery", reduced to a month on appeal. Laith says the police also tried to get him to inform on other gay people he knew of.
"[The policeman] said: 'I can fabricate a whole story about you if you don't give me names.'"
The Egyptian government has spoken publicly about its use of online surveillance to target what it described as "homosexual gatherings".
In 2020, Ahmed Taher, former assistant to the Minister of Interior for Internet Crimes and Human Trafficking, told the newspaper Ahl Masr: "We recruited police in the virtual world to uncover the masses of group sex parties, homosexual gatherings."
The UK Foreign Commonwealth and Development Office told the BBC that no UK funding has gone towards training for the Egyptian police in activities relevant to the claims made in the investigation.
UK MP Alicia Kearns, chair of the Foreign Affairs Committee, told the BBC that she wanted more to be done to warn LGBT travellers about the risks in countries such as Egypt, "where their sexuality might be weaponised against them".
"I would urge the Egyptian government to cease all activities which target individuals on the basis of their sexual orientation."
The Egyptian government did not respond to the BBC's request for comment.
The WhosHere app was referenced in nearly every police transcript the BBC has had access to.
Cyber privacy experts told us that WhosHere seems to have specific vulnerabilities, allowing hackers to scrape information about its users - such as location - on a large scale.
And they say the way WhosHere is collecting and storing data is likely in breach of privacy laws in the UK and the EU.
It was only after the BBC formally approached WhosHere that the app changed its settings, removing the "seeking same sex" selection, which could put people at risk of identification.
WhosHere disputes the BBC's findings about vulnerabilities and say that they have a robust history of addressing problems when raised. And that they do not operate any specific service for the LGBT community in Egypt.
Grindr, also used as an app by police and criminals to find LGBT people in Egypt said: "We work extensively with Egyptian LGBTQ activists, international human rights advocates, and safety-focused technologists to best serve our users in the region."
Criminal gangs are using the same tactics as the police to find LGBT people. They then attack and humiliate them, and extort them by threatening to post the videos online.
I managed to track down two people we are calling Laila and Jamal, who were victims of a video that went viral in Egypt a few years ago.
The footage shows them being forced to strip and dance, while being beaten and abused. They are forced at knife point to give their full names and admit they are gay.
They told me the duo behind the video - named Bakar and Yahia - are notorious amongst the community.
We saw at least four videos in which Bakar and Yahia either appeared, or could be heard, extorting and abusing LGBT people before they uploaded the videos to Whatsapp, YouTube and Facebook.
In one of these videos, an 18-year-old gay man we are calling Saeed is forced to, falsely, say he is a sex worker.
I met him to hear about what happened next. He told me that he considered legal action but says his lawyer advised against this, telling him his sexuality would be perceived as more of a crime than the attack he suffered.
Saeed is now alienated from his family. He says they cut him off when the gang sent them the video in a bid to blackmail them too.
"I have been suffering from depression after what happened, with the videos circulating to all my friends in Egypt. I don't go out, and I don't have a phone.
"No-one used to know anything about me."
We've been told about dozens of attacks like this - carried out by multiple gangs. There are only a few reports of attackers being arrested.
It shocked me to learn, in the course of investigation that one gang leader, Yahia, is gay and actively posting online about his own sex work.
But perhaps it gives him a criminal edge - he knows just how vulnerable his targets are. And arguably his own position, as a gay man with little opportunity, fuels his criminality.
We have no evidence that Yahia has been involved in recent attacks, and he has denied involvement in any of the attacks.
Covering any of these issues inside Egypt itself has been banned since 2017, when the country's Supreme Council for Media Regulation imposed a media blackout on LGBT representation except if the coverage "acknowledge[s] the fact that their conduct is inappropriate".
LGBT community advocates, many of them in exile, are divided over whether the problems in Egypt should be highlighted in the media or tackled behind the scenes.
But Laila, Saeed, Jamal and Laith have chosen to step out of the shadows and break the silence.