## Hashing vs Encryption

They are often confused but are opposite concepts.

| Feature | Encryption | Hashing |
|---|---|---|
| **Reversible?** | **YES** (with key). | **NO** (One-way). |
| **Purpose** | Confidentiality. | Integrity. |
| **Output Size** | Variable (Depends on input). | Fixed (e.g., 256 bits). |
| **Examples** | AES, RSA. | SHA-256, MD5. |

### Hashing Use Cases
1.  **Password Storage**: Never save passwords as text. Save the hash. When user logs in, hash their input and compare it to the database.
2.  **File Integrity**: Download a file. Check its MD5. If it matches the website, the file involves no corruption or malware injection.