Encryption works by encoding information before it is transmitted to protect sensitive data like passwords and personal information. There are two main types of encryption: symmetric-key encryption where both computers use the same secret key, and public-key encryption which uses different keys for encryption and decryption. Encryption along with authentication, which verifies the source and integrity of information, provide security for data transmitted over the internet and between computers.