Encryption works by using keys to scramble data before transmitting it, then using the same key to unscramble it upon receipt. There are two main types: symmetric key encryption which uses the same key by both parties, and public key encryption which uses different keys but relates them through hashing. Public key encryption addressed weaknesses in symmetric key encryption by allowing secure communication without pre-sharing a key. Hashing algorithms are used to generate hash values from data in public key encryption in a way that makes deriving the original data nearly impossible without the hash value.