## Definitions

Cryptography
From the Greek meaning 'hidden writing'
Cipher
A secret or disguised way of writing something
Code
A system of symbols or words used to represent other meanings. Sometimes used for the purposes of secrecy
Encryption
Turning something communicable information into gibberish. Comes from latin meaning 'hidden'
Decryption
Turning gibberish into meaning
Ciphers
Symmetric, Asymmetric, Quantum
Symmetric cipher
This is where the key is used on both sides of encryption/decryption
Quantum cipher
Weird physics stuff
Asymmetric cipher
'Public key' cryptography, where a message is encoded with a public key, but can only be decoded with another private key. Ideal for transferring over a distance
Keys
Any data used to encrypt something, the more complex the better
Can be a memorable word or phrase or random string, used as a key
Entropy
Measuring the effectiveness of a key, measured in bits
Hashing
Reducing something into a unique value, usually one way reduction. An essential process of encryption
Digital signing
Changing a document in such a way to leave a 'signature' from the person who made the change
Cryptoanalysis
The process of trying to discover a codes algorithm or vulnerabilities and using that to break the code

An analogy is the lock and key. We don't particularly know the inner workings of the lock, and that is a good thing! We do have a key though, so at least we can get in, and the lock can prevent others from getting in. The cypher is the lock, and the key is, well, the key. The lock can be opened or closed using the key - this is enciphering (encoding) and deciphering (decoding).

## Codes

A code is like a puzzle, it just takes time to solve it. No system is 100% foolproof. Time is a factor in many ways. How clever/complicated a code is to crack means it will take years for a normal computer hack. Also, for a code to be useful in encoding/decoding it needs to be able to be of a useful speed. For example, logging into a website does not have to be instantaneous (this makes things tougher for a brute force attack) but also needs to be fast enough for the user to not be perturbed.

A simple example of a code could be a 'substitution cipher', where characters are substituted:

``````a b c d e f g h i j k l m n o p q r s t u v w x y z
``````

The key:

``````w g m u p b l y a r i q v k f n d t c o x e z j s h
``````
``````const key = { a: 'w', b: 'g', c: 'm', d: 'u', e: 'p', f: 'b', g: 'l', h: 'y', i: 'a', j: 'r', k: 'i', l: 'q', m: 'v', n: 'k', o: 'f', p: 'n', q: 'd', r: 't', s: 'c', t: 'o', u: 'x', v: 'e', w: 'z', x: 'j', y: 's', z: 'h', };

const decodeKey = (() => Object.keys(key).reduce((curr, next) => {
curr[key[next]] = next;
return curr;
}, {}))();

function encipher(plaintext) {
return plaintext.split('').map(char => key[char] || '*').join('');
}

function decipher(plaintext) {
return plaintext.split('').map(char => decodeKey[char] || ' ').join('');
}
``````

So using the key to cipher the 'plaintext' string 'i am a little teapot' would return `a*wv*w*qaooqp*opwnfo`. As you can see, they key is the thing used to encode/decode a message.