# Cryptography/Classical Cryptography

Cryptography has a long and colorful history from Caesar's encryption in first century BC to the 20th century.
There are two major principles in classical cryptography: transposition and substitution.

## Transposition ciphers

Lets look first at transposition, which is the changing in the position of the letters in the message such as a simple writing backwards
or as in a more complex transposition such as:
then take the columns:
(the extra letters are called space fillers) The idea in transposition is NOT to randomize it but to transform it to something that is not recognizable with a reversible algorithm (an algorithm is just a procedure, reversible so your correspondent can read the message).
We discuss transposition ciphers in much more detail in a later chapter, Cryptography/Transposition ciphers.

## Substitution ciphers

The second most important principle is substitution. That is, substituting a Symbol for a letter of your plaintext (or word or even sentence). Slang even can sometimes be a form of cipher (the symbols replacing your plaintext), ever wonder why your parents never understood you? Slang, though, is not something you would want to store a secret in for a long time. In WWII, there were Navajo CodeTalkers who passed along info from unit to unit. From what I hear (someone verify this) the Navajo language was a very exclusive almost unknown and unwritten language. So the Japanese were not able to decipher it.
Even though this is a very loose example of substitution, whatever works works.

## Caesar Cipher

One of the most basic methods of encryption is the use of Caesar Ciphers. It simply consist in shifting the alphabet over a few characters and matching up the letters.
The classical example of a substitution cipher is a shifted alphabet cipher
Example:(using cipher 2)
If this is the first time you've seen this it may seem like a rather secure cipher, but it's not. In fact this by itself is very insecure. For a time in the 1500-1600s this was the most secure (mainly because there were many people who were illiterate) but a man (old what's his name) in the 18th century discovered a way to crack (find the hidden message) of every cipher of this type he discovered frequency analysis.
We discuss substitution ciphers in much more detail in a later chapter, Cryptography/Substitution ciphers.

## Frequency Analysis

In the shifted alphabet cipher or any simple randomized cipher, the same letter in the cipher replaces each of the same ones in your message (e.g. 'A' replaces all 'D's in the plaintext, etc.). The weakness is that English uses certain letters more than any other letter in the alphabet. 'E' is the most common, etc. Here's an exercise count all of each letter in this article. You'll find that in the previous sentence there are 2 'H's,7 'E's, 3 'R's, 3 'S's, etc. By far 'E' is the most common letter; here are the other frequencies [Frequency tables|http://rinkworks.com/words/letterfreq.shtml]. Basically you experiment with replacing different symbols with letters (the most common with 'E', etc.).
First look for short words with limited choices of words, such as 'KP' this may be at, in, to, or, by, etc. Let us select in. Replace 'K' with 'I' and 'P' with 'N'.
Next select VJG this is most likely the (since the huge frequency of 'the' in a normal sentence, check a couple of the preceding sentences).
generally this in much easier in long messages the plaintext is 'THE RAIN IN SPAIN'
We discuss many different ways to "attack", "break", and "solve" encrypted messages in a later section of this book, "Part III: Cryptanalysis", which includes a much more detailed section on Cryptography/Frequency analysis.

## Combining transposition and substitution

A more secure encryption is a transposed substitution cipher.
Take the above message in encrypted form
now spiral transpose it
The message starts in the upper right corner and spirals to the center (again the AA is a filler) Now take the columns:
Now this is more resistant to Frequency analysis, see what we did before that started recognizable patterns results in:
A problem for people who crack codes.

## Multiliteral systems

The vast majority of classical ciphers are "uniliteral" -- they encrypt a plaintext 1 letter at a time, and each plaintext letter is encrypted to a single corresponding ciphertext letter.
A multiliteral system is one where the ciphertext unit is more than one character in length. The major types of multiliteral systems are:
* biliteral systems: 2 letters of ciphertext per letter of plaintext
* dinomic systems: 2 digits of ciphertext per letter of plaintext
* Triliteral systems: 3 letters of ciphertext per letter of plaintext
* trinomic systems: 3 digits of ciphertext per letter of plaintext
* monome-dinome systems, also called straddling checkerboard systems: 1 digit of ciphertext for some plaintext letters, 2 digits of ciphertext for the remaining plaintext letters.
* biliteral with variants and dinomic with variants systems: several ciphertext values decode to the same plaintext letter (homophonic substitution cipher)
* Syllabary square systems: 2 letters or 2 digits of ciphertext decode to an entire syllable or a single character of plaintext.
* ↑ Field Manual 34-40-2 "Chapter 5: Monoalphabetic Multiliteral Substitution Systems".
* ↑ "The Syllabary Cipher".