The British IT expert hailed a hero for foiling ‘the biggest ransomware offensive in history’ has appeared in a US court over allegations that he confessed to creating an illegal computer code to harvest people’s bank details.

23-year-old Marcus Hutchins won global fame in May, after working from a room in the house he shares with his parents in Devon to defeat the WannaCry ransomware attack, which had crippled the NHS and spread to computers in 150 countries.

But on Friday, he was led into a Las Vegas courtroom wearing a prison-issue jumpsuit to hear claims he created another form of malware called Kronos, and then conspired between July 2014 and July 2015 to advertise and sell it on internet forums.

If convicted, he could face up to 40 years in a US jail.

Alleging that Hutchins had confessed during a police interview, prosecutor Dan Cowhig told the court: “He admitted he was the author of the code of Kronos malware, and indicated he sold it.”

Mr Cowhig claimed that Hutchins – known in cybersecurity circles as MalwareTech – and his unnamed co-defendant, thought to be still at large, were found out in a sting operation involving undercover officers buying the code.

Prosecutors claim the software was sold for 2,000 dollars (£1,522) in digital currency in June 2015.

Other evidence came from chat logs where Hutchins complained to the co-defendant that he did not receive a fair share of the money, Mr Cowhig said.

Hutchins, however, is expected to deny all six charges against him.

He retains widespread support among the cybersecurity and IT community, some of whom have expressed serious concerns about what is thought to have been a two-year FBI operation against him.

Speaking outside court, computer law expert Tor Ekeland said: “This is a very, very problematic prosecution, and I think it’s bizarre that the United States government has chosen to prosecute somebody who’s arguably their hero in the WannaCry malware attack, and who’s potentially saved lives and thousands, hundreds of thousands, if not millions, of dollars over the sale of alleged malware.”

Claiming the prosecution had only offered flimsy evidence so far, Mr Ekeland said he found it striking that the indictment didn’t allege any financial loss to any victims – or in any way identify them.

“The only money mentioned in this indictment is ... for the sale of the software,” he said.

His concerns were echoed by Kurt Opsahl, deputy executive director of digital civil liberties group the Electronic Frontier Foundation, which is helping Hutchins with his defence case.

Mr Opsahl said outside court: “Security researchers are vital to protecting the computers we rely upon every day. Mr Hutchins’ arrest has unfortunately deepened the divide between the research community and the government.”

Gadget and tech news: In pictures Show all 25 1 /25 Gadget and tech news: In pictures Gadget and tech news: In pictures Gun-toting humanoid robot sent into space Russia has launched a humanoid robot into space on a rocket bound for the International Space Station (ISS). The robot Fedor will spend 10 days aboard the ISS practising skills such as using tools to fix issues onboard. Russia's deputy prime minister Dmitry Rogozin has previously shared videos of Fedor handling and shooting guns at a firing range with deadly accuracy. Dmitry Rogozin/Twitter Gadget and tech news: In pictures Google turns 21 Google celebrates its 21st birthday on September 27. The The search engine was founded in September 1998 by two PhD students, Larry Page and Sergey Brin, in their dormitories at California’s Stanford University. Page and Brin chose the name google as it recalled the mathematic term 'googol', meaning 10 raised to the power of 100 Google Gadget and tech news: In pictures Hexa drone lifts off Chief engineer of LIFT aircraft Balazs Kerulo demonstrates the company's "Hexa" personal drone craft in Lago Vista, Texas on June 3 2019 Reuters Gadget and tech news: In pictures Project Scarlett to succeed Xbox One Microsoft announced Project Scarlett, the successor to the Xbox One, at E3 2019. The company said that the new console will be 4 times as powerful as the Xbox One and is slated for a release date of Christmas 2020 Getty Gadget and tech news: In pictures First new iPod in four years Apple has announced the new iPod Touch, the first new iPod in four years. The device will have the option of adding more storage, up to 256GB Apple Gadget and tech news: In pictures Folding phone may flop Samsung will cancel orders of its Galaxy Fold phone at the end of May if the phone is not then ready for sale. The $2000 folding phone has been found to break easily with review copies being recalled after backlash PA Gadget and tech news: In pictures Charging mat non-starter Apple has cancelled its AirPower wireless charging mat, which was slated as a way to charge numerous apple products at once AFP/Getty Gadget and tech news: In pictures "Super league" India shoots down satellite India has claimed status as part of a "super league" of nations after shooting down a live satellite in a test of new missile technology EPA Gadget and tech news: In pictures 5G incoming 5G wireless internet is expected to launch in 2019, with the potential to reach speeds of 50mb/s Getty Gadget and tech news: In pictures Uber halts driverless testing after death Uber has halted testing of driverless vehicles after a woman was killed by one of their cars in Tempe, Arizona. March 19 2018 Getty Gadget and tech news: In pictures A humanoid robot gestures during a demo at a stall in the Indian Machine Tools Expo, IMTEX/Tooltech 2017 held in Bangalore Getty Gadget and tech news: In pictures A humanoid robot gestures during a demo at a stall in the Indian Machine Tools Expo, IMTEX/Tooltech 2017 held in Bangalore Getty Gadget and tech news: In pictures Engineers test a four-metre-tall humanoid manned robot dubbed Method-2 in a lab of the Hankook Mirae Technology in Gunpo, south of Seoul, South Korea Jung Yeon-Je/AFP/Getty Gadget and tech news: In pictures Engineers test a four-metre-tall humanoid manned robot dubbed Method-2 in a lab of the Hankook Mirae Technology in Gunpo, south of Seoul, South Korea Jung Yeon-Je/AFP/Getty Gadget and tech news: In pictures The giant human-like robot bears a striking resemblance to the military robots starring in the movie 'Avatar' and is claimed as a world first by its creators from a South Korean robotic company Jung Yeon-Je/AFP/Getty Gadget and tech news: In pictures Engineers test a four-metre-tall humanoid manned robot dubbed Method-2 in a lab of the Hankook Mirae Technology in Gunpo, south of Seoul, South Korea Jung Yeon-Je/AFP/Getty Gadget and tech news: In pictures Waseda University's saxophonist robot WAS-5, developed by professor Atsuo Takanishi Rex Gadget and tech news: In pictures Waseda University's saxophonist robot WAS-5, developed by professor Atsuo Takanishi and Kaptain Rock playing one string light saber guitar perform jam session Rex Gadget and tech news: In pictures A test line of a new energy suspension railway resembling the giant panda is seen in Chengdu, Sichuan Province, China Reuters Gadget and tech news: In pictures A test line of a new energy suspension railway, resembling a giant panda, is seen in Chengdu, Sichuan Province, China Reuters Gadget and tech news: In pictures A concept car by Trumpchi from GAC Group is shown at the International Automobile Exhibition in Guangzhou, China Rex Gadget and tech news: In pictures A Mirai fuel cell vehicle by Toyota is displayed at the International Automobile Exhibition in Guangzhou, China Reuters Gadget and tech news: In pictures A visitor tries a Nissan VR experience at the International Automobile Exhibition in Guangzhou, China Reuters Gadget and tech news: In pictures A man looks at an exhibit entitled 'Mimus' a giant industrial robot which has been reprogrammed to interact with humans during a photocall at the new Design Museum in South Kensington, London Getty Gadget and tech news: In pictures A new Israeli Da-Vinci unmanned aerial vehicle manufactured by Elbit Systems is displayed during the 4th International conference on Home Land Security and Cyber in the Israeli coastal city of Tel Aviv Getty

Hutchins was arrested on Wednesday as he prepared to return home from Las Vegas, after attending the Def Con convention for computer security professionals.

He smiled to the press packing the public gallery as he was led into the court on Friday, dressed in bright orange Crocs shoes and a yellow jumpsuit with the word “detainee” stamped on the back.

He spoke softly as he answered procedural questions and confirmed his identity.

District Judge Nancy Koppe ordered his release on bail, saying he has no criminal history and the allegations date back two years.

She was also impressed by letters from cybersecurity colleagues.

Despite being granted bail, Hutchins will not be released until Monday because his supporters and family were unable to raise the 30,000 dollars (£23,000) bond money in the brief period between the hearing ending and the court closing on Friday afternoon.

The conditions of his bail are that he cannot access the internet, must be monitored by GPS, surrender his passport and only reside in Clark County, Nevada, or within the Eastern District of Wisconsin where he will appear in court on Tuesday.

Hutchins, who works for Los Angeles-based computer security firm Kryptos Logic, is expected to formally enter his pleas at Tuesday’s hearing.

After Friday’s court appearance, Hutchins’ lawyer Adrian Lobo said her client was innocent.

“He has dedicated his life to researching malware, not trying to harm people,” she said. “What he has done is use the internet for good.

“He was completely shocked [by his arrest]. He came here for a work-related conference. He was fully anticipating to go back home and had no reason to be fearful of coming or going from the US.”

​Hutchins’ mother Janet has said she was “outraged” by the arrest, stressing that it was “hugely unlikely” her son was involved because he spends much of his time combating malware attacks.

Hutchins has also been backed by his local MP. Peter Heaton-Jones, the Conservative MP for North Devon, has written to Foreign Office minister Sir Alan Duncan to seek assurance that Hutchins is receiving adequate consular assistance.

He acknowledged the UK cannot interfere with the American proceedings and said he has made no judgement about the guilt of Hutchins, but added: “People who know him in Ilfracombe, and in the wider cyber-community, are astounded at the allegations against him.