A handwritten notebook by British Second World War code-breaking genius Alan Turing, whose story was portrayed in the 2014 Oscar-winning movie The Imitation Game, has been sold for more than one million dollars (£685,000).

Bonhams auctioned the 56-page manuscript - believed to be the only extensive Turing manuscript known to exist.

Part of the proceeds will be donated to charity.

Turing spent his early years in Upper Maze Hill, St Leonards. In 2012 a blue plaque was unveiled at the house on what would have been his 100th birthday.

He went to day school locally in Charles Road before going to Sherborne School, Dorset.

The notebook was written at the time the mathematician and computer science pioneer was working to break the seemingly unbreakable Enigma codes used by the Germans throughout the war.

It contains Turing's complex mathematical and computer science notations.

The Imitation Game, starring Benedict Cumberbatch as Turing, won the Oscar for Best Adapted Screenplay.

The sale also includes a working German Enigma enciphering machine. The three-rotor device, manufactured for the German military in July 1944, is estimated to sell for 140,000 to 180,000 dollars (£95,900-£123,000).

Turing was prosecuted for being gay at a time when it was illegal in Britain. He was convicted of indecency in 1952 and agreed to undergo hormone treatment as an alternative to imprisonment to "cure" his homosexuality.

He died in 1954 of cyanide poisoning, which was ruled a suicide, although his family and friends believed it might have been accidental. The notebook was among the papers he left in his will to friend and fellow mathematician Robin Gandy.

Mr Gandy gave the papers to The Archive Centre at King's College in Cambridge in 1977. But he kept the notebook, using its blank pages for writing down his dreams at the request of his psychiatrist.

Bonham describes Mr Gandy's entries as highly personal; the notebook remained in his possession until he died in 1995.

At the beginning of his journal, Mr Gandy writes: "It seems a suitable disguise to write in between these notes of Alan's on notation, but possibly a little sinister; a dead father figure, some of whose thoughts I most completely inherited."

Bonhams said the seller wished to remain anonymous.