General Overview of Cryptographic Functions
Cryptography is in use just about everywhere protecting your online transactions to validating your identity. If you are looking for detailed information on the implementation of popular encryption algorithms such as AES or Serpent, or are looking for information on anything other than classical cryptography (i.e. quantum cryptography) this is the wrong overview, but if you want some general information about the types of cryptographic functions and how they can be combined to do many useful things, this is for you.
Two of the main types of cryptographic functions are hash functions and encryption functions. Let's begin with hash functions. A hash function takes an input and returns an output based on that input, but at a fixed length, and it is a one-way function, meaning that it has no inverse. Because it can return an output shorter than the input, the output is non-unique. In practice, good cryptographic hash functions return duplicate values for extremely different inputs. This means that slightly changing the input should still change the output. At first glance, this type of function might seem useless. However, the fact that it is not easily reversible makes it valuable in a variety of scenarios. Suppose that you operate a website that users log into, so you also have to be able to verify their passwords. Although you could simply store their passwords in a database, what happens if someone nefarious gets that database? All of your users' passwords are now compromised. If, however, you hash the user's password when he or she signs up and store the hash in the database and then compare the hash of the submitted password to the password in the database when the user tries to log in, you can still verify that the correct password is entered without having to store the actual password. If a nefarious person gets the password hashes, he or she would have to try a brute-force attack, trying all possible password values. Although a hash collision (multiple inputs return same output) could occur, most good hash algorithms make this extremely unlikely. You may ask why the length of the hash is set at a fixed value, when it could be done without any hash collisions if the hash could be just as long as the input. Although this could likely be done, inputs are often fairly large and such a hash would often be impractical.
The second type is an encryption function. There are two main types of ways to set them up: with asymmetric keys and with a symmetric key. Symmetric encryption is what most people think of when they think about encryption. You use the same key to both encrypt and decrypt data. Asymmetric encryption is far more interesting. The RSA encryption standard is perhaps the best-known private/public (asymmetric) key algorithm. In this method of encryption, two keys are created. Data encrypted using one key cannot be decrypted with that same key, only the other one. This means that I can share my public key with everyone, and everyone can send me encrypted information, but only I can decipher it because only I have my private key. Similarly, I can verify that I am the author of a message. I do this by using my private key to encrypt a hash of my message which anyone can read using my public key. They then compare this to the hash of my message. If they match, I am almost certainly the one who sent the message. This verification is called a digital signature. It is secure because if someone wants to forge my digital signature, he or she would have to learn my private key.