A Royal Navy petty officer has been jailed for eight years for trying to pass Britain's nuclear submarine secrets to men he believed to be Russian spies.
Edward Devenney, 30, was told he had betrayed his country and his colleagues.
Mr Justice Saunders, sentencing him at the Old Bailey, said Devenney knew what he was doing when he met the two men in January.
He added: "He did supply details of movements and operations carried out and to be carried out by nuclear submarines. I am satisfied that in the wrong hands it was capable of affecting the operational effectiveness of nuclear submarines. This is a very serious case. The defendant was prepared to betray his country and his colleagues."
Devenney, from Northern Ireland, had suffered as the result of a rape allegation of which he was later cleared. But by January this year, when he met the men in London, Devenney was a "controlled and rational man".
No damage had actually been done to national security because the Russians were in fact MI5 intelligence officers, but Devenney had not known that at the time. Devenney pleaded guilty to breaching the Official Secrets Act by gathering classified information and misconduct by meeting the supposed spies.
The court heard that Devenney rang the Russian embassy in November last year, after what he said was a 12-hour drinking binge. He thought he had been treated badly by the Royal Navy because he was not promoted to chief petty officer.
Two days later, he managed to get into a locked safe on board HMS Vigilant and take three photographs of part of a secret code for encrypted information. The judge said: "The photographs could, with other information, have led to the breaking of the code."
He added: "The defendant made determined efforts to enter into an agreement to supply secret information to representatives of another country. The reason he later gave for his actions was that he wished to get his own back on the Royal Navy who he considered had treated him badly." But the judge added: "The objective evidence is that the Royal Navy treated him well."
Lord Carlile, for Devenney, read out a statement from him which said: "I would like to apologise for the shame I brought on the Royal Navy." He said Devenney had been "something of a blue-eyed boy" until things began to go awry. The rape allegation led to a general collapse in Devenney's behaviour.