(CNN) A rare Enigma machine used by Nazi Germany during World War II was sold at auction Tuesday for 45,000 euros ($51,500).

The collector who put the machine up for sale at the Artmark auction house in Bucharest, Romania, had spotted it at a flea market in the city and bought it for just 100 euros ($114).

Vitally important to Nazi war efforts, the Enigma machine was used by the German military to encrypt messages into a form they believed was unbreakable.

But the code was cracked by a team of cryptologists at Bletchley Park in southern England -- a breakthrough widely credited with having shortened the war by at least two years.

The instrument sold Tuesday -- to an unnamed online bidder -- was made in Germany in 1941 and is in almost perfect condition, Vlad Georgescu, relationship manager at Artmark, told CNN.

Enigma machines were used by the German military during World War II to encrypt messages.