Codes and ciphers have been used for centuries to conceal messages between confidants. A typical system would revolve around a key, which is a bunch of data that describes a recipe for encrypting or decrypting a message. In olden days, it might have been a table written on paper describing how to encode. More recently, keys used with computer encryption are just data files.
In general, the more complicated a key is, that is, the more data that's needed by both sides, the harder it is for any eavesdropper to break the code. After all, they have to guess all that data. Of course, it's easier to steal the whole thing, but usually codes are figured out when a few encoded messages are intercepted along with the plain text that they tells the real message. Sometimes it's possible to reverse engineer the code, so you have to make the code more difficult to break.
Military codes, for instance, were encoded using special code books. Each page decscribed a different code. Each time a message was sent, it was encrypted using the code on a page, then that page was ripped out, never to be used again. (Hopefully the sender and receiver would be ripping out pages in synchrony.) This way, even if the enemy managed to find the plain text for one message, along with its encrypted version, other messages, past and future, were safe.
The problem with this scheme was that the code books had to be securely sent to each remote confidant. This was typically accomplished by having an agent (a human, typically bearing firearms for self protection) physically carry the code books in a briefcase handcuffed to the agent. Those of us without access to a military budget did our best with more primitive methods.
The encryption breakthrough of the 1970's was Public Key Encryption. With Public Key Encryption, two confidants can communicate securely, even if all of their communications are intercepted. This is all done without risking sending a secret key, which would give any eavesdropper all they need to break the code.
In Public Key Encryption, the key is broken into two parts: your Secret Key is kept secret on your computer, and your Public Key is given out to each confidant. Presumably, eavesdroppers also get a copy of the Public Key, but this is OK. The Public Key allows confidants (or eavesdroppers as the case may be) only to encrypt a message to you. Public Keys cannot be used for decryption; only your Secret Key can decrypt such messages.
Typically, each confidant has their own Secret Key, and also has a collection of the Public Keys of all of the people they communicate with. An eavesdropper will only have Public Keys, and cannot decrypt anything.
Go to Allan's Glossary of Encryption.
Go to Allan's' Help Desk.