Espionage and intelligence is a activity that is employed by nations and corporations in order to gather information about the activities of their competitors and their enemies. This can range from sending in agents to the opponent's personnel structure to listening in to their radio communications.
There is no nation that doesn't make use of espionage but these activities are increased during a time of war and conflict. The most important activity of a intelligence agency/operation is to determine the locations and targets of enemy units/vessels/etc. Because of the uncertain nature of the gathering of intelligence, it is not always a possibility to gain a full picture of your enemies intentions and activities.
Countermeasures to enemy intelligence activities include specialized couriers for the delivering of military orders(delivering them directly to the unit commanders) to computerized encryption of radio signals. Often even with the usage of encryption technology the use of code words is often still used to further keep messages secure. These countermeasures are not fool proof, however. This is why changing codes and encryption keys is vital to maintaining security. Even the best mechanical/electrical methods can be cracked by a determined intelligence effort.
This is best displayed by the British and American cracking of both the Nazi Enigma machine and the Japanese JN25 naval codes. Because of their belief that their systems were unbreakable the Nazis never changed the main operating principles of how their machines operated making it easy for the British code crackers to recheck the system whenever a change was made in the operating procedures as the Nazis(with the exception of the submarine fleet adding a 4th wheel) never changed the basic mechanical design of the coding machines. With the creation of what can be called the first electronic computer, the Colossus, by Alan Turing the Allies were soon able to read German dispatches almost as fast, or faster, as the German unit commanders. Operation Overlord owes much of its success to Operation Ultra encryption agents. Encryption efforts also play a large influence in the Battle of Midway with the breaking of the JN25 Naval code just before the battle. in this case, because of the heavy use of code words on the part of the Japanese the target was not initially certain to the decryption agents of the US Navy but using a clever ruse, a blind request for fresh water, they were able to confirm the suspicion that the target was Midway Island.