Encrypting a message by substitution involves taking each part of it (usually each letter, though it can be done word by word) and substituting it for something else. Any symbol can be used, but for simplicity of sending and writing the encrypted message, the same letters of the alphabet are generally used. For instance, A might be substituted with G, B with K and so on.
The receiver needs to know the substitution method - because in this case it is also the key to decryption - to decipher the message. In Roman times, Caesar used to shift the letters of the alphabet along three places:
letters: abcdefghijklmnopqrstuvwxyz code letters: DEFGHIJKLMNOPQRSTUVWXYZABC example text: caesar shouted the guard as the girl ran away code text: FDHVDU VKRXWHG WKH JXDUG DV WKH JLUO UDQ DZDB
As long as the receiver knows the method being used is to shift the letters three to the right, he can read the code text by shifting them back three places to the left - once again, as long as he knows the key (in this case the method of encryption), he can decrypt the message.
Punctuation can be included also to form a bigger set of substitutions. Any general substitution method of this sort is called the monoalphabetic substitution cipher.
A better way still is to have the code letters in a more random placement. This can be done easily (and made easy for the recipient to remember the key) with the use of a keyword. The keyword is agreed on, and then the letters of this are used to form the start of the substitution code, with the rest of the alphabet making up the other letters, for example:
Using the keyword "DR STUART J PORTER" First take out the spaces and any duplicated letters:
DRSTUAJPOE
Now use this as the start of the code letters, and use the rest of the alphabet in alphabetical order from the last letter used to fill up the rest:
letters: abcdefghijklmnopqrstuvwxyz code letters: DRSTUAJPOEFGHIKLMNQVWXYZBC keyword || other letters example text: the lecturer has got his flies undone code text: VPU GUSVWNUN PDQ JKV POQ AGOUQ WITKIU
As long as my friends in the class know that the keyword is the lecturer's name, they can all create the code letters in order as written above, and use this in reverse to understand the message.