A code was a system to convert a piece of information into another form. Codes were most often used to send messages or define situations.
Codes were often used to encrypt information, including the Federation's Code 2 and Code 3 in the 23rd century; the former had been broken by the Romulans by stardate 3478.2, and thus was replaced by the latter. (TOS: "The Deadly Years")
Many other codes were simply used to transmit information quickly, including Code One alert to indicate a declaration of war or disaster, (TOS: "Errand of Mercy") Code 710 to indicate planetary quarantine, (TOS: "A Taste of Armageddon") Code 1-Alpha-Zero for a ship in distress, (TNG: "Relics") Code Factor 1 for a possible invasion of the Federation, (TOS: "The Alternative Factor") code blue, or blue alert, used to indicate a change in starship flight status, (TNG: "Brothers") code white resuscitation to indicate the need to resuscitate a dead individual, (VOY: "Initiations") Emergency Code 1 for intruder alert, (TNG: "The High Ground") and Transporter Code 14 to destroy an object in a transporter beam. (TNG: "Captain's Holiday")
Critical ship systems required pass-phrase access in the form of prefix codes (Star Trek II: The Wrath of Khan; TNG: "The Wounded") and authorization codes. (Star Trek: First Contact; VOY: "Deadlock", "Dreadnought", "Cathexis", "Renaissance Man"; TNG: "Chain of Command, Part I")