Cipher
Information can be encrypted in two basic ways, cipher and code. Ciphers apply an algorithm and a cryptographic key to plaintext in the form of bits or characters; the process of encryption is unaware of linguistic structure such as words. It would make no difference to a cipher if its inputs were the complete works of William Shakespeare, a digitized image of a toxic waste dump, the closing price of every stock on the Tokyo stock exchange, or an order to invade Vatican City.
Most often, there is a one-to-one correspondence between the elements — bits or bytes &mdash of the plaintext, although some ciphers insert nomsense padding into the ciphertext, to lessen the statistical relationship between plaintext and ciphertext. Padding that was mistaken for plaintext has changed the course of battles.
Another technique for hiding the real message content is called masking, which is used on dedicated communications channels. On a channel where there is no cost for transmission, essentially random noise, in the form that does not appear superficially different than the encrypted messages, is transmitted whenever there is no traffic to send.
Basic cipher paradigms
There are two fundamental approaches in ciphers, which strong systems combine. Substitution exchanges ciphertext for plaintext. As a trivial example, assume a substitution cipher shifts letters one place in the alphabet, so ZEBRAS would becone AFCSBT.
The alternative, 'transposition, changes the order of the plaintext elements. As a different trivial example, assume a trivial transposition exchanges the order of each pair of letters, so ZEBRAS would become EZRBSA.
Combining operations
As a simple example of the multiple operations in real ciphers, if the mechanism were substitution followed by transposition, ZEBRAS would become FASCTB. Transposition followed by substitution would convert ZEBRAS to FASCTB.
Increasing key length
Real-world systems, of course, are much more complex, typically performing transposition and substitution on chunks of plaintext far longer than a few bits, and with a complex variable key. The example of substitution above was monoalphabetic, with the same transformation applied to each symbol of plaintext. For a slightly more complex example that is polyalphabetic, shift the odd letters one alphabetic place and the even letters two places, so that ZEBRAS becomes AGCTBU.
A one-time pad, which is demostrably unbreakable, has a totally random key of the same length of the message.