What is hashing and how does it differ from encryption?

Answer

Hashing is a one-way transformation of data into a fixed-size digest using a hash function (MD5, SHA-256, bcrypt). It is irreversible — you cannot get the original data from the hash. Encryption is two-way — data can be decrypted back to the original with the correct key. Key use cases for hashing: Password storage (never store plaintext passwords — store the hash), data integrity verification (compare hash of downloaded file to expected hash), digital signatures. For password hashing, use adaptive algorithms like bcrypt, scrypt, or Argon2 — they are slow by design (adjustable work factor) to resist brute force. Avoid MD5 and SHA-1 for security purposes (both are cryptographically broken). Always use salting with password hashes to prevent rainbow table attacks.