Ciphers

Introduction

These pages are intended as notes for programmers interested in writing programs based on codes and ciphers. Most of the pages contain pseudocode, with varying levels of detail, to help you to program a solution. The pseudocode describes programs that can be written in most high level languages. Scripting languages and console programs will work fine for almost all of the examples.

Pseudocode is used to avoid specifying a language for the section. Decryption algorithms are described in some places but should be easily derived from the encryption algorithms if they have not been listed. The key parts of the algorithms have been shown, often in parts. You'll have to think about what you are doing. Functions, procedures and classes have not been used but should be part of your approach if you are an A level student.

The algorithms are not always the most efficient and not always the most compact way of expressing the steps. That is deliberate to make them easier to follow and to show how a core set of steps can be varied for ciphers of the same family. It also gives you the basis for exploring a little further with the topic.

Codes & Ciphers

This section of the site is concerned mainly with ciphers but there are some codes discussed too. Although many people use the two terms interchangeably, a distinction is made in classical cryptography.

We use a code, like Morse code, to substitute each character in our message for a pattern of dots and dashes, short and long bursts of light or sound. The coded patterns consist of 2 characters, repreated and combined into strings whose length varies from one character to another. The purpose of such a code is to allow an alphabet of 36 or more characters to be communicated using only 2 characters. Many codes, like Morse, are not concerned with obscuring the meaning of the message being communicated. More often, the code, like Semaphore, is designed to make it possible to communicate the message in the first place.

Ciphers are used exclusively for making messages difficult or impossible to understand for anyone other than the intended recipient of the message. Whereas a code will usually require a code book or some reference that, if discovered, would render the code useless for keeping informaton secret, most ciphers do not. Indeed, for many ciphers, the tables or references used for deciphering the message can be constructed simply from previously agreed keywords.

TermDefinition
cipherThe cipher is the system you use to change the plain text into cipher text.
cipher alphabetThe characters that are used in the cipher text. The cipher alphabet is usually stored in order of which plain text character is being substituted.
cipher textThe message after the cipher has been applied.
cryptanalysisThe study of ciphers and cipher text with a view to uncovering weaknesses that allow the plain text to be retrieved.
cryptographyThe practice and study of techniques for communicating information securely.
decrypt, decipherCipher text is decrypted or deciphered to turn it into plain text.
digraphA digraph is a pair of letters. Digraphic substitution ciphers substitute two adjacent characters in the plain text for a different combination of characers.
encrypt, encipherPlain text is encrypted or enciphered to turn it into cipher text.
key, keywordThe key to a cipher is the information required to be able to encrypt or decrypt a message. The key might be a word or phrase that is used to construct the cipher alphabet. The key might be a number, a route or a template that is used to transpose cipher text into plain text. Often the key is known to sender and receiver prior to communication but, in some cases, is embedded in the message.
messageThe information that is being communicated. In most of the examples in this section, the information being communicated is text, usually just letters. Some numeric information or an image might also be a message too.
monoalphabeticA term used with substitution ciphers where each character in the plain text is substituted with only one other character.
monographicA term used with substitution ciphers where characters are substituted one at a time.
plain alphabetThe characters that can be communicated using a cipher. Some ciphers have no provision for characters other than letters, some use a shortened alphabet.
plain textThe name we give to a message before anything has been done to it.
polyalphabeticA term used with substitution ciphers where each character in the plain text is substituted for one of several possible letters.
polygraphicA term used with substitution ciphers where groups of characters in the plain text are substituted at a time for different combinations of characters.
Polybius squareA square grid into which characters are written. The co-ordinates of each character are used when enciphering a message.
steganographyThe practice of hiding one message within another.
substitution cipherA family of ciphers where characters in the plain text are substituted for different characters in the cipher text.
transposition cipherA family of ciphers where characters in the plain text are rearranged according to an algorithm.