Someone in Romania thought he'd made a fair amount of money when he sold an old typewriter for €100 ($115) at a flea market. He was wrong.

The "typewriter" was, in fact, a German Wehrmacht Enigma I, a World War II cipher machine, and the collector who bought it put it up for sale at the Bucharest auction house Artmark with a starting price of €9,000. On Tuesday, Artmark sold it to an online bidder for €45,000.

"The collector bought it from a flea market. He's a cryptography professor and ... he knew very well what he was buying," said Cristian Gavrila, the collectible consignment manager at Artmark.

Romania was an ally of Nazi Germany until 1944, when it switched sides to the allies. Historians say it may host many other cryptographic machines not yet discovered.

Last month, Christie's New York Books set a world auction record of $547,500 with its sale of what it labeled a "four-rotor Enigma cipher machine, 1944," to an online bidder.

The Enigma was used to encode and decode messages sent by the various branches of the Nazi military, but the British mathematician Alan Turing and his team at Britain's wartime code-breaking center, Bletchley Park, cracked the codes. By some estimates, their work shortened the war by two years.