As World War II neared an end, the Japanese planned a massive use of suicide weapons including kamikaze frogmen and human torpedoes in a last-ditch attempt to stop the United States from invading Japan.

In the last months of the war, according to secret documents just released by the code-breaking National Security Agency, the Japanese Navy trained a force of 800 underwater demolition experts whose mission was to blow themselves up against the bottoms of landing ships as they approached Japanese beaches.

The same documents reveal that the Japanese Navy also recruited as many as 1,000 "human torpedoes" who were trained to sit astride surface-launched torpedoes and pilot them into the hulls of American warships.

In fact, the "Kaiten" suicide torpedo was used by Japanese in the last three months of the war and may have been responsible for the sinking of an American destroyer, the USS Underhill, lost off Okinawa the night of July 24, 1945.

A cable decoded by the United States three days later mentions that at least two Kaiten torpedoes had been used in the attack launched from Japanese torpedo boats against the Underhill.

These are a few of the facts gleaned by the "code-breakers" who were the forerunners during World War II of today's supersecret National Security Agency. In an operation called "Magic," American cryptographic experts broke Japan's most secret diplomatic code as early as the fall of 1940 and kept the code-breaking a secret until the end of the war.

The NSA has now released more than 60 bound documents detailing Japanese cable traffic from the first month of the war to the last. One thing clearly emerges about the Japanese state of mind in the war's last months: they were so desperate, they planned to make suicide a keystone of their strategy against invasion.

"The emphasis in training will be on improving suicide aircraft and surface and underwater suicide strength," read a cable to all military field commanders less than a month before the first atomic bomb fell on Japan. "Air strategy is to be based on total suicide air attacks."

In "Operation Homeland," which involved the retraining of hundreds of thousands of sailors and noncombat troops to defend Japan against invasion, the emphasis in training was on suicide charges against tanks.

On July 7, 1945, according to the decoded cable traffic, the Japanese activated 14 "Special Landing Forces" of 1,000 men apiece whose mission was to strap explosives to their bodies and hurl themselves at tanks.

At the same time, the Japanese Navy set up as many as 40 squadrons of suicide crash boats. Production priority was given to midget submarines, whose two-man crews were trained in suicide collision tactics to destroy enemy warships.

Japan's Navy also ordered all submarines and destroyers to be equipped with as many as five of the Kaiten suicide torpedoes, which were launched from the surface with a human pilot strapped to the torpedo's frame.

The Kaiten torpedo was to be Japan's main line of defense against attack from the sea. By the end of July 1945, as many as 40 suicide bases from which surface ships and submarines could put out with Kaiten torpedoes had been set up along the Japanese coast. By Aug. 9, the day the second atomic bomb fell on Japan, as many as 1,000 "human torpedoes" were on alert.

By the same date, more than 800 frogmen were in training "for surprise underwater attacks" using a new type of diving suit. The suicide frogmen were to be backups to the human torpedoes.

Meanwhile, the Japanese Air Force was converting its fighter planes, dive bombers and torpedo planes to kamikazes. It began to fly raw recruits in kamikaze training planes, navigating them to sea at night by the use of searchlights along the way.

The air force also planned to put skilled fighter pilots into the cockpits of ancient biplanes, whose wood and fabric frames made them hard for American radar to detect. One decoded cable claimed that one of these slow biplanes had crashed into the USS Callahan, sinking it immediately.

So desperate were Japan's final hours that it began to use fast-burning alcohol as an aircraft fuel and to store aviation fuel in caves instead of tanks above ground. On at least three occasions, according to the decoded cables, the Japanese moved troops on hospital ships to avoid attack.

By July, 1945, the Japanese had no battleships, one cruiser and one aircraft carrier. The fleet also had 32 destroyers and 45 submarines.

In the last months of the war, the United States was sinking 73,000 tons of Japanese shipping a week. In June alone, 90 Japanese merchant ships aggregating 290,000 tons were sunk. A single airraid on the city of Aamori in North Honshu in late July left 90 percent of the city's population homeless.

When the first atomic bomb fell on Hiroshima, the Japanese instructed their fighter pilots to "fire at all parachutes" during air attacks since the first atomic bomb had fallen by parachute. When the second bomb fell on Nagasaki, one decoded message read: "There is no defense measure against these weapons."